| 1330 | } |
| 1331 | |
| 1332 | int RtmpStreamBase::SendAudioMessage(const RtmpAudioMessage& msg) { |
| 1333 | if (_rtmpsock == NULL) { |
| 1334 | errno = EPERM; |
| 1335 | return -1; |
| 1336 | } |
| 1337 | if (_chunk_stream_id == 0) { |
| 1338 | LOG(ERROR) << __FUNCTION__ << " can't be called before play() is received"; |
| 1339 | errno = EPERM; |
| 1340 | return -1; |
| 1341 | } |
| 1342 | if (_paused) { |
| 1343 | errno = EPERM; |
| 1344 | return -1; |
| 1345 | } |
| 1346 | SocketMessagePtr<policy::RtmpUnsentMessage> msg2(new policy::RtmpUnsentMessage); |
| 1347 | msg2->header.timestamp = msg.timestamp; |
| 1348 | msg2->header.message_length = msg.size(); |
| 1349 | msg2->header.message_type = policy::RTMP_MESSAGE_AUDIO; |
| 1350 | msg2->header.stream_id = _message_stream_id; |
| 1351 | msg2->chunk_stream_id = _chunk_stream_id; |
| 1352 | // Make audio header. |
| 1353 | const char audio_head = |
| 1354 | ((msg.codec & 0xF) << 4) |
| 1355 | | ((msg.rate & 0x3) << 2) |
| 1356 | | ((msg.bits & 0x1) << 1) |
| 1357 | | (msg.type & 0x1); |
| 1358 | msg2->body.push_back(audio_head); |
| 1359 | msg2->body.append(msg.data); |
| 1360 | return _rtmpsock->Write(msg2); |
| 1361 | } |
| 1362 | |
| 1363 | int RtmpStreamBase::SendAACMessage(const RtmpAACMessage& msg) { |
| 1364 | if (_rtmpsock == NULL) { |