正在显示
2 个修改的文件
包含
17 行增加
和
7 行删除
@@ -258,7 +258,7 @@ int SrsFlvEncoder::write_video(int32_t timestamp, char* data, int size) | @@ -258,7 +258,7 @@ int SrsFlvEncoder::write_video(int32_t timestamp, char* data, int size) | ||
258 | return ret; | 258 | return ret; |
259 | } | 259 | } |
260 | 260 | ||
261 | -int SrsFlvEncoder::write_tag(char* header, int header_size, char* data, int size) | 261 | +int SrsFlvEncoder::write_tag(char* header, int header_size, char* tag, int tag_size) |
262 | { | 262 | { |
263 | int ret = ERROR_SUCCESS; | 263 | int ret = ERROR_SUCCESS; |
264 | 264 | ||
@@ -269,7 +269,7 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* data, int size | @@ -269,7 +269,7 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* data, int size | ||
269 | } | 269 | } |
270 | 270 | ||
271 | // write tag data. | 271 | // write tag data. |
272 | - if ((ret = _fs->write(data, size, NULL)) != ERROR_SUCCESS) { | 272 | + if ((ret = _fs->write(tag, tag_size, NULL)) != ERROR_SUCCESS) { |
273 | srs_error("write flv tag failed. ret=%d", ret); | 273 | srs_error("write flv tag failed. ret=%d", ret); |
274 | return ret; | 274 | return ret; |
275 | } | 275 | } |
@@ -279,7 +279,7 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* data, int size | @@ -279,7 +279,7 @@ int SrsFlvEncoder::write_tag(char* header, int header_size, char* data, int size | ||
279 | if ((ret = tag_stream->initialize(pre_size, 4)) != ERROR_SUCCESS) { | 279 | if ((ret = tag_stream->initialize(pre_size, 4)) != ERROR_SUCCESS) { |
280 | return ret; | 280 | return ret; |
281 | } | 281 | } |
282 | - tag_stream->write_4bytes(size + header_size); | 282 | + tag_stream->write_4bytes(tag_size + header_size); |
283 | if ((ret = _fs->write(pre_size, sizeof(pre_size), NULL)) != ERROR_SUCCESS) { | 283 | if ((ret = _fs->write(pre_size, sizeof(pre_size), NULL)) != ERROR_SUCCESS) { |
284 | srs_error("write flv previous tag size failed. ret=%d", ret); | 284 | srs_error("write flv previous tag size failed. ret=%d", ret); |
285 | return ret; | 285 | return ret; |
@@ -75,24 +75,34 @@ public: | @@ -75,24 +75,34 @@ public: | ||
75 | SrsFlvEncoder(); | 75 | SrsFlvEncoder(); |
76 | virtual ~SrsFlvEncoder(); | 76 | virtual ~SrsFlvEncoder(); |
77 | public: | 77 | public: |
78 | + /** | ||
79 | + * initialize the underlayer file stream, | ||
80 | + * user can initialize multiple times to encode multiple flv files. | ||
81 | + */ | ||
78 | virtual int initialize(SrsFileStream* fs); | 82 | virtual int initialize(SrsFileStream* fs); |
79 | public: | 83 | public: |
80 | /** | 84 | /** |
81 | * write flv header. | 85 | * write flv header. |
82 | - * user can invoke this method multiple times, | ||
83 | - * for example, when get audio/video sequence header. | ||
84 | - * | ||
85 | * write following: | 86 | * write following: |
86 | * 1. E.2 The FLV header | 87 | * 1. E.2 The FLV header |
87 | * 2. PreviousTagSize0 UI32 Always 0 | 88 | * 2. PreviousTagSize0 UI32 Always 0 |
88 | * that is, 9+4=13bytes. | 89 | * that is, 9+4=13bytes. |
89 | */ | 90 | */ |
90 | virtual int write_header(); | 91 | virtual int write_header(); |
92 | + /** | ||
93 | + * write flv metadata. | ||
94 | + * serialize from: | ||
95 | + * AMF0 string: onMetaData, | ||
96 | + * AMF0 object: the metadata object. | ||
97 | + */ | ||
91 | virtual int write_metadata(char* data, int size); | 98 | virtual int write_metadata(char* data, int size); |
99 | + /** | ||
100 | + * write audio/video packet. | ||
101 | + */ | ||
92 | virtual int write_audio(int32_t timestamp, char* data, int size); | 102 | virtual int write_audio(int32_t timestamp, char* data, int size); |
93 | virtual int write_video(int32_t timestamp, char* data, int size); | 103 | virtual int write_video(int32_t timestamp, char* data, int size); |
94 | private: | 104 | private: |
95 | - virtual int write_tag(char* header, int header_size, char* data, int size); | 105 | + virtual int write_tag(char* header, int header_size, char* tag, int tag_size); |
96 | }; | 106 | }; |
97 | 107 | ||
98 | /** | 108 | /** |
-
请 注册 或 登录 后发表评论