正在显示
6 个修改的文件
包含
15 行增加
和
10 行删除
| @@ -273,7 +273,7 @@ int SrsDvrPlan::on_meta_data(SrsOnMetaDataPacket* metadata) | @@ -273,7 +273,7 @@ int SrsDvrPlan::on_meta_data(SrsOnMetaDataPacket* metadata) | ||
| 273 | } | 273 | } |
| 274 | SrsAutoFree(char, payload); | 274 | SrsAutoFree(char, payload); |
| 275 | 275 | ||
| 276 | - if ((ret = enc->write_metadata(payload, size)) != ERROR_SUCCESS) { | 276 | + if ((ret = enc->write_metadata(18, payload, size)) != ERROR_SUCCESS) { |
| 277 | return ret; | 277 | return ret; |
| 278 | } | 278 | } |
| 279 | 279 |
| @@ -110,7 +110,7 @@ int SrsFlvEncoder::write_header(char flv_header[9]) | @@ -110,7 +110,7 @@ int SrsFlvEncoder::write_header(char flv_header[9]) | ||
| 110 | return ret; | 110 | return ret; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | -int SrsFlvEncoder::write_metadata(char* data, int size) | 113 | +int SrsFlvEncoder::write_metadata(char type, char* data, int size) |
| 114 | { | 114 | { |
| 115 | int ret = ERROR_SUCCESS; | 115 | int ret = ERROR_SUCCESS; |
| 116 | 116 | ||
| @@ -118,7 +118,7 @@ int SrsFlvEncoder::write_metadata(char* data, int size) | @@ -118,7 +118,7 @@ int SrsFlvEncoder::write_metadata(char* data, int size) | ||
| 118 | 118 | ||
| 119 | // 11 bytes tag header | 119 | // 11 bytes tag header |
| 120 | static char tag_header[] = { | 120 | static char tag_header[] = { |
| 121 | - (char)18, // TagType UB [5], 18 = script data | 121 | + (char)type, // TagType UB [5], 18 = script data |
| 122 | (char)0x00, (char)0x00, (char)0x00, // DataSize UI24 Length of the message. | 122 | (char)0x00, (char)0x00, (char)0x00, // DataSize UI24 Length of the message. |
| 123 | (char)0x00, (char)0x00, (char)0x00, // Timestamp UI24 Time in milliseconds at which the data in this tag applies. | 123 | (char)0x00, (char)0x00, (char)0x00, // Timestamp UI24 Time in milliseconds at which the data in this tag applies. |
| 124 | (char)0x00, // TimestampExtended UI8 | 124 | (char)0x00, // TimestampExtended UI8 |
| @@ -66,12 +66,13 @@ public: | @@ -66,12 +66,13 @@ public: | ||
| 66 | virtual int write_header(char flv_header[9]); | 66 | virtual int write_header(char flv_header[9]); |
| 67 | /** | 67 | /** |
| 68 | * write flv metadata. | 68 | * write flv metadata. |
| 69 | + * @param type, the type of data, or other message type. | ||
| 69 | * @param data, the amf0 metadata which serialize from: | 70 | * @param data, the amf0 metadata which serialize from: |
| 70 | * AMF0 string: onMetaData, | 71 | * AMF0 string: onMetaData, |
| 71 | * AMF0 object: the metadata object. | 72 | * AMF0 object: the metadata object. |
| 72 | * @remark assert data is not NULL. | 73 | * @remark assert data is not NULL. |
| 73 | */ | 74 | */ |
| 74 | - virtual int write_metadata(char* data, int size); | 75 | + virtual int write_metadata(char type, char* data, int size); |
| 75 | /** | 76 | /** |
| 76 | * write audio/video packet. | 77 | * write audio/video packet. |
| 77 | * @remark assert data is not NULL. | 78 | * @remark assert data is not NULL. |
| @@ -843,8 +843,11 @@ int srs_rtmp_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char | @@ -843,8 +843,11 @@ int srs_rtmp_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char | ||
| 843 | // detach bytes from packet. | 843 | // detach bytes from packet. |
| 844 | msg->payload = NULL; | 844 | msg->payload = NULL; |
| 845 | } else { | 845 | } else { |
| 846 | - // ignore and continue | ||
| 847 | - continue; | 846 | + *type = msg->header.message_type; |
| 847 | + *data = (char*)msg->payload; | ||
| 848 | + *size = (int)msg->size; | ||
| 849 | + // detach bytes from packet. | ||
| 850 | + msg->payload = NULL; | ||
| 848 | } | 851 | } |
| 849 | 852 | ||
| 850 | // got expected message. | 853 | // got expected message. |
| @@ -1714,7 +1717,7 @@ int srs_flv_write_tag(srs_flv_t flv, char type, int32_t time, char* data, int si | @@ -1714,7 +1717,7 @@ int srs_flv_write_tag(srs_flv_t flv, char type, int32_t time, char* data, int si | ||
| 1714 | } else if (type == SRS_RTMP_TYPE_VIDEO) { | 1717 | } else if (type == SRS_RTMP_TYPE_VIDEO) { |
| 1715 | return context->enc.write_video(time, data, size); | 1718 | return context->enc.write_video(time, data, size); |
| 1716 | } else { | 1719 | } else { |
| 1717 | - return context->enc.write_metadata(data, size); | 1720 | + return context->enc.write_metadata(type, data, size); |
| 1718 | } | 1721 | } |
| 1719 | 1722 | ||
| 1720 | return ret; | 1723 | return ret; |
| @@ -2476,8 +2479,8 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int | @@ -2476,8 +2479,8 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int | ||
| 2476 | srs_freep(amf0_str); | 2479 | srs_freep(amf0_str); |
| 2477 | } | 2480 | } |
| 2478 | } else { | 2481 | } else { |
| 2479 | - srs_human_trace("Unknown packet type=%s, dts=%d, pts=%d, size=%d", | ||
| 2480 | - srs_human_flv_tag_type2string(type), timestamp, pts, size); | 2482 | + srs_human_trace("Unknown packet type=%#x, dts=%d, pts=%d, size=%d", |
| 2483 | + type, timestamp, pts, size); | ||
| 2481 | } | 2484 | } |
| 2482 | 2485 | ||
| 2483 | return ret; | 2486 | return ret; |
| @@ -241,6 +241,7 @@ extern int srs_rtmp_bandwidth_check(srs_rtmp_t rtmp, | @@ -241,6 +241,7 @@ extern int srs_rtmp_bandwidth_check(srs_rtmp_t rtmp, | ||
| 241 | * SRS_RTMP_TYPE_AUDIO, FlvTagAudio | 241 | * SRS_RTMP_TYPE_AUDIO, FlvTagAudio |
| 242 | * SRS_RTMP_TYPE_VIDEO, FlvTagVideo | 242 | * SRS_RTMP_TYPE_VIDEO, FlvTagVideo |
| 243 | * SRS_RTMP_TYPE_SCRIPT, FlvTagScript | 243 | * SRS_RTMP_TYPE_SCRIPT, FlvTagScript |
| 244 | +* otherswise, invalid type. | ||
| 244 | * @param timestamp, in ms, overflow in 50days | 245 | * @param timestamp, in ms, overflow in 50days |
| 245 | * @param data, the packet data, according to type: | 246 | * @param data, the packet data, according to type: |
| 246 | * FlvTagAudio, @see "E.4.2.1 AUDIODATA" | 247 | * FlvTagAudio, @see "E.4.2.1 AUDIODATA" |
| @@ -460,7 +460,7 @@ VOID TEST(KernelFlvTest, FlvEncoderWriteMetadata) | @@ -460,7 +460,7 @@ VOID TEST(KernelFlvTest, FlvEncoderWriteMetadata) | ||
| 460 | }; | 460 | }; |
| 461 | char pts[] = { (char)0x00, (char)0x00, (char)0x00, (char)19 }; | 461 | char pts[] = { (char)0x00, (char)0x00, (char)0x00, (char)19 }; |
| 462 | 462 | ||
| 463 | - ASSERT_TRUE(ERROR_SUCCESS == enc.write_metadata(md, 8)); | 463 | + ASSERT_TRUE(ERROR_SUCCESS == enc.write_metadata(18, md, 8)); |
| 464 | ASSERT_TRUE(11 + 8 + 4 == fs.offset); | 464 | ASSERT_TRUE(11 + 8 + 4 == fs.offset); |
| 465 | 465 | ||
| 466 | EXPECT_TRUE(srs_bytes_equals(tag_header, fs.data, 11)); | 466 | EXPECT_TRUE(srs_bytes_equals(tag_header, fs.data, 11)); |
-
请 注册 或 登录 后发表评论