| 1398 | } |
| 1399 | |
| 1400 | int RtmpStreamBase::SendVideoMessage(const RtmpVideoMessage& msg) { |
| 1401 | if (_rtmpsock == NULL) { |
| 1402 | errno = EPERM; |
| 1403 | return -1; |
| 1404 | } |
| 1405 | if (_chunk_stream_id == 0) { |
| 1406 | LOG(ERROR) << __FUNCTION__ << " can't be called before play() is received"; |
| 1407 | errno = EPERM; |
| 1408 | return -1; |
| 1409 | } |
| 1410 | if (!policy::is_video_frame_type_valid(msg.frame_type)) { |
| 1411 | LOG(WARNING) << "Invalid frame_type=" << (int)msg.frame_type; |
| 1412 | } |
| 1413 | if (!policy::is_video_codec_valid(msg.codec)) { |
| 1414 | LOG(WARNING) << "Invalid codec=" << (int)msg.codec; |
| 1415 | } |
| 1416 | if (_paused) { |
| 1417 | errno = EPERM; |
| 1418 | return -1; |
| 1419 | } |
| 1420 | SocketMessagePtr<policy::RtmpUnsentMessage> msg2(new policy::RtmpUnsentMessage); |
| 1421 | msg2->header.timestamp = msg.timestamp; |
| 1422 | msg2->header.message_length = msg.size(); |
| 1423 | msg2->header.message_type = policy::RTMP_MESSAGE_VIDEO; |
| 1424 | msg2->header.stream_id = _message_stream_id; |
| 1425 | msg2->chunk_stream_id = _chunk_stream_id; |
| 1426 | // Make video header |
| 1427 | const char video_head = ((msg.frame_type & 0xF) << 4) | (msg.codec & 0xF); |
| 1428 | msg2->body.push_back(video_head); |
| 1429 | msg2->body.append(msg.data); |
| 1430 | return _rtmpsock->Write(msg2); |
| 1431 | } |
| 1432 | |
| 1433 | int RtmpStreamBase::SendAVCMessage(const RtmpAVCMessage& msg) { |
| 1434 | if (_rtmpsock == NULL) { |