正在显示
7 个修改的文件
包含
301 行增加
和
4 行删除
@@ -482,6 +482,7 @@ Supported operating systems and hardware: | @@ -482,6 +482,7 @@ Supported operating systems and hardware: | ||
482 | * 2013-10-17, Created.<br/> | 482 | * 2013-10-17, Created.<br/> |
483 | 483 | ||
484 | ## History | 484 | ## History |
485 | +* v2.0, 2014-11-20, fix [#212](https://github.com/winlinvip/simple-rtmp-server/issues/212), support publish audio raw frames. 2.0.27 | ||
485 | * v2.0, 2014-11-19, fix [#213](https://github.com/winlinvip/simple-rtmp-server/issues/213), support compile [srs-librtmp on windows](https://github.com/winlinvip/srs.librtmp), [bug #213](https://github.com/winlinvip/simple-rtmp-server/issues/213). 2.0.26 | 486 | * v2.0, 2014-11-19, fix [#213](https://github.com/winlinvip/simple-rtmp-server/issues/213), support compile [srs-librtmp on windows](https://github.com/winlinvip/srs.librtmp), [bug #213](https://github.com/winlinvip/simple-rtmp-server/issues/213). 2.0.26 |
486 | * v2.0, 2014-11-18, all wiki translated to English. 2.0.23. | 487 | * v2.0, 2014-11-18, all wiki translated to English. 2.0.23. |
487 | * v2.0, 2014-11-15, fix [#204](https://github.com/winlinvip/simple-rtmp-server/issues/204), srs-librtmp drop duplicated sps/pps(sequence header). 2.0.22. | 488 | * v2.0, 2014-11-15, fix [#204](https://github.com/winlinvip/simple-rtmp-server/issues/204), srs-librtmp drop duplicated sps/pps(sequence header). 2.0.22. |
@@ -6,7 +6,8 @@ else | @@ -6,7 +6,8 @@ else | ||
6 | ST_ALL = objs/srs_flv_parser \ | 6 | ST_ALL = objs/srs_flv_parser \ |
7 | objs/srs_flv_injecter objs/srs_publish objs/srs_play \ | 7 | objs/srs_flv_injecter objs/srs_publish objs/srs_play \ |
8 | objs/srs_ingest_flv objs/srs_ingest_rtmp objs/srs_detect_rtmp \ | 8 | objs/srs_ingest_flv objs/srs_ingest_rtmp objs/srs_detect_rtmp \ |
9 | - objs/srs_bandwidth_check objs/srs_h264_raw_publish | 9 | + objs/srs_bandwidth_check objs/srs_h264_raw_publish \ |
10 | + objs/srs_audio_raw_publish | ||
10 | endif | 11 | endif |
11 | 12 | ||
12 | .PHONY: default clean help ssl nossl | 13 | .PHONY: default clean help ssl nossl |
@@ -24,6 +25,7 @@ help: | @@ -24,6 +25,7 @@ help: | ||
24 | @echo " srs_flv_injecter inject keyframes information to metadata." | 25 | @echo " srs_flv_injecter inject keyframes information to metadata." |
25 | @echo " srs_publish publish program using srs-librtmp" | 26 | @echo " srs_publish publish program using srs-librtmp" |
26 | @echo " srs_h264_raw_publish publish raw h.264 stream to SSR by srs-librtmp" | 27 | @echo " srs_h264_raw_publish publish raw h.264 stream to SSR by srs-librtmp" |
28 | + @echo " srs_audio_raw_publish publish raw audio stream to SSR by srs-librtmp" | ||
27 | @echo " srs_play play program using srs-librtmp" | 29 | @echo " srs_play play program using srs-librtmp" |
28 | @echo " srs_ingest_flv ingest flv file and publish to RTMP server." | 30 | @echo " srs_ingest_flv ingest flv file and publish to RTMP server." |
29 | @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server." | 31 | @echo " srs_ingest_rtmp ingest RTMP and publish to RTMP server." |
@@ -85,6 +87,9 @@ objs/srs_publish: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBR | @@ -85,6 +87,9 @@ objs/srs_publish: srs_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBR | ||
85 | objs/srs_h264_raw_publish: srs_h264_raw_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | 87 | objs/srs_h264_raw_publish: srs_h264_raw_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) |
86 | $(GCC) srs_h264_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_h264_raw_publish | 88 | $(GCC) srs_h264_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_h264_raw_publish |
87 | 89 | ||
90 | +objs/srs_audio_raw_publish: srs_audio_raw_publish.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | ||
91 | + $(GCC) srs_audio_raw_publish.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_audio_raw_publish | ||
92 | + | ||
88 | objs/srs_play: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) | 93 | objs/srs_play: srs_play.c $(SRS_RESEARCH_DEPS) $(SRS_LIBRTMP_I) $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) |
89 | $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_play | 94 | $(GCC) srs_play.c $(SRS_LIBRTMP_L) $(SRS_LIBSSL_L) $(EXTRA_CXX_FLAG) -o objs/srs_play |
90 | 95 |
1 | +/* | ||
2 | +The MIT License (MIT) | ||
3 | + | ||
4 | +Copyright (c) 2013-2014 winlin | ||
5 | + | ||
6 | +Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
7 | +this software and associated documentation files (the "Software"), to deal in | ||
8 | +the Software without restriction, including without limitation the rights to | ||
9 | +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
10 | +the Software, and to permit persons to whom the Software is furnished to do so, | ||
11 | +subject to the following conditions: | ||
12 | + | ||
13 | +The above copyright notice and this permission notice shall be included in all | ||
14 | +copies or substantial portions of the Software. | ||
15 | + | ||
16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
18 | +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
19 | +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
20 | +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
21 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
22 | +*/ | ||
23 | +/** | ||
24 | +gcc srs_audio_raw_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_audio_raw_publish | ||
25 | +*/ | ||
26 | + | ||
27 | +#include <stdio.h> | ||
28 | +#include <stdlib.h> | ||
29 | +#include <unistd.h> | ||
30 | + | ||
31 | +// for open audio raw file. | ||
32 | +#include <sys/types.h> | ||
33 | +#include <sys/stat.h> | ||
34 | +#include <fcntl.h> | ||
35 | + | ||
36 | +#include "../../objs/include/srs_librtmp.h" | ||
37 | + | ||
38 | +// https://github.com/winlinvip/simple-rtmp-server/issues/212#issuecomment-63648892 | ||
39 | +// allspace: | ||
40 | +// Take this file as an example: https://github.com/allspace/files/blob/master/srs.pcm | ||
41 | +// It's captured using SDK callback method. I have filtered out h264 video, so it's audio only now. | ||
42 | +// For every frame, it's a 8 bytes vendor specific header, following 160 bytes audio frame. | ||
43 | +// The header part can be ignored. | ||
44 | +int read_audio_frame(char* audio_raw, int file_size, char** pp, char** pdata, int* psize) | ||
45 | +{ | ||
46 | + char* p = *pp; | ||
47 | + | ||
48 | + if (file_size - (p - audio_raw) < 168) { | ||
49 | + srs_lib_trace("audio must be 160+8 bytes. left %d bytes.", | ||
50 | + file_size - (p - audio_raw)); | ||
51 | + return - 1; | ||
52 | + } | ||
53 | + | ||
54 | + // ignore 8bytes vendor specific header. | ||
55 | + p += 8; | ||
56 | + | ||
57 | + // 160 bytes audio frame | ||
58 | + *pdata = p; | ||
59 | + *psize = 160; | ||
60 | + | ||
61 | + // next frame. | ||
62 | + *pp = p + *psize; | ||
63 | + | ||
64 | + return 0; | ||
65 | +} | ||
66 | + | ||
67 | +int main(int argc, char** argv) | ||
68 | +{ | ||
69 | + printf("publish raw audio as rtmp stream to server like FMLE/FFMPEG/Encoder\n"); | ||
70 | + printf("SRS(simple-rtmp-server) client librtmp library.\n"); | ||
71 | + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | ||
72 | + | ||
73 | + if (argc <= 2) { | ||
74 | + printf("Usage: %s <audio_raw_file> <rtmp_publish_url>\n", argv[0]); | ||
75 | + printf(" audio_raw_file: the audio raw steam file.\n"); | ||
76 | + printf(" rtmp_publish_url: the rtmp publish url.\n"); | ||
77 | + printf("For example:\n"); | ||
78 | + printf(" %s ./audio.raw.pcm rtmp://127.0.0.1:1935/live/livestream\n", argv[0]); | ||
79 | + printf("Where the file: http://winlinvip.github.io/srs.release/3rdparty/audio.raw.pcm\n"); | ||
80 | + printf("See: https://github.com/winlinvip/simple-rtmp-server/issues/212\n"); | ||
81 | + exit(-1); | ||
82 | + } | ||
83 | + | ||
84 | + const char* raw_file = argv[1]; | ||
85 | + const char* rtmp_url = argv[2]; | ||
86 | + srs_lib_trace("raw_file=%s, rtmp_url=%s", raw_file, rtmp_url); | ||
87 | + | ||
88 | + // open file | ||
89 | + int raw_fd = open(raw_file, O_RDONLY); | ||
90 | + if (raw_fd < 0) { | ||
91 | + srs_lib_trace("open audio raw file %s failed.", raw_fd); | ||
92 | + goto rtmp_destroy; | ||
93 | + } | ||
94 | + | ||
95 | + off_t file_size = lseek(raw_fd, 0, SEEK_END); | ||
96 | + if (file_size <= 0) { | ||
97 | + srs_lib_trace("audio raw file %s empty.", raw_file); | ||
98 | + goto rtmp_destroy; | ||
99 | + } | ||
100 | + srs_lib_trace("read entirely audio raw file, size=%dKB", (int)(file_size / 1024)); | ||
101 | + | ||
102 | + char* audio_raw = (char*)malloc(file_size); | ||
103 | + if (!audio_raw) { | ||
104 | + srs_lib_trace("alloc raw buffer failed for file %s.", raw_file); | ||
105 | + goto rtmp_destroy; | ||
106 | + } | ||
107 | + | ||
108 | + lseek(raw_fd, 0, SEEK_SET); | ||
109 | + ssize_t nb_read = 0; | ||
110 | + if ((nb_read = read(raw_fd, audio_raw, file_size)) != file_size) { | ||
111 | + srs_lib_trace("buffer %s failed, expect=%dKB, actual=%dKB.", | ||
112 | + raw_file, (int)(file_size / 1024), (int)(nb_read / 1024)); | ||
113 | + goto rtmp_destroy; | ||
114 | + } | ||
115 | + | ||
116 | + // connect rtmp context | ||
117 | + srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url); | ||
118 | + | ||
119 | + if (srs_simple_handshake(rtmp) != 0) { | ||
120 | + srs_lib_trace("simple handshake failed."); | ||
121 | + goto rtmp_destroy; | ||
122 | + } | ||
123 | + srs_lib_trace("simple handshake success"); | ||
124 | + | ||
125 | + if (srs_connect_app(rtmp) != 0) { | ||
126 | + srs_lib_trace("connect vhost/app failed."); | ||
127 | + goto rtmp_destroy; | ||
128 | + } | ||
129 | + srs_lib_trace("connect vhost/app success"); | ||
130 | + | ||
131 | + if (srs_publish_stream(rtmp) != 0) { | ||
132 | + srs_lib_trace("publish stream failed."); | ||
133 | + goto rtmp_destroy; | ||
134 | + } | ||
135 | + srs_lib_trace("publish stream success"); | ||
136 | + | ||
137 | + u_int32_t timestamp = 0; | ||
138 | + u_int32_t time_delta = 17; | ||
139 | + // @remark, to decode the file. | ||
140 | + char* p = audio_raw; | ||
141 | + for (;p < audio_raw + file_size;) { | ||
142 | + // @remark, read a frame from file buffer. | ||
143 | + char* data = NULL; | ||
144 | + int size = 0; | ||
145 | + if (read_audio_frame(audio_raw, file_size, &p, &data, &size) < 0) { | ||
146 | + srs_lib_trace("read a frame from file buffer failed."); | ||
147 | + goto rtmp_destroy; | ||
148 | + } | ||
149 | + | ||
150 | + // 0 = Linear PCM, platform endian | ||
151 | + // 1 = ADPCM | ||
152 | + // 2 = MP3 | ||
153 | + // 7 = G.711 A-law logarithmic PCM | ||
154 | + // 8 = G.711 mu-law logarithmic PCM | ||
155 | + // 10 = AAC | ||
156 | + // 11 = Speex | ||
157 | + char sound_format = 1; | ||
158 | + // 3 = 44 kHz | ||
159 | + char sound_rate = 3; | ||
160 | + // 1 = 16-bit samples | ||
161 | + char sound_size = 1; | ||
162 | + // 1 = Stereo sound | ||
163 | + char sound_type = 1; | ||
164 | + | ||
165 | + timestamp += time_delta; | ||
166 | + | ||
167 | + if (srs_audio_write_raw_frame(rtmp, | ||
168 | + sound_format, sound_rate, sound_size, sound_type, | ||
169 | + 0, data, size, timestamp) != 0 | ||
170 | + ) { | ||
171 | + srs_lib_trace("send audio raw data failed."); | ||
172 | + goto rtmp_destroy; | ||
173 | + } | ||
174 | + | ||
175 | + srs_lib_trace("sent packet: type=%s, time=%d, size=%d, codec=%d, rate=%d, sample=%d, channel=%d", | ||
176 | + srs_type2string(SRS_RTMP_TYPE_AUDIO), timestamp, size, sound_format, sound_rate, sound_size, | ||
177 | + sound_type); | ||
178 | + | ||
179 | + // @remark, when use encode device, it not need to sleep. | ||
180 | + usleep(1000 * time_delta); | ||
181 | + } | ||
182 | + | ||
183 | +rtmp_destroy: | ||
184 | + srs_rtmp_destroy(rtmp); | ||
185 | + close(raw_fd); | ||
186 | + free(audio_raw); | ||
187 | + | ||
188 | + return 0; | ||
189 | +} | ||
190 | + |
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | // current release version | 31 | // current release version |
32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
34 | -#define VERSION_REVISION 26 | 34 | +#define VERSION_REVISION 27 |
35 | // server info. | 35 | // server info. |
36 | #define RTMP_SIG_SRS_KEY "SRS" | 36 | #define RTMP_SIG_SRS_KEY "SRS" |
37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" | 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" |
@@ -1439,6 +1439,46 @@ char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize) | @@ -1439,6 +1439,46 @@ char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize) | ||
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | /** | 1441 | /** |
1442 | +* write audio raw frame to SRS. | ||
1443 | +*/ | ||
1444 | +int srs_audio_write_raw_frame(srs_rtmp_t rtmp, | ||
1445 | + char sound_format, char sound_rate, char sound_size, char sound_type, | ||
1446 | + char aac_packet_type, char* frame, int frame_size, u_int32_t timestamp | ||
1447 | +) { | ||
1448 | + int ret = ERROR_SUCCESS; | ||
1449 | + | ||
1450 | + Context* context = (Context*)rtmp; | ||
1451 | + srs_assert(context); | ||
1452 | + | ||
1453 | + // TODO: FIXME: for aac, must send the sequence header first. | ||
1454 | + | ||
1455 | + // for audio frame, there is 1 or 2 bytes header: | ||
1456 | + // 1bytes, SoundFormat|SoundRate|SoundSize|SoundType | ||
1457 | + // 1bytes, AACPacketType for SoundFormat == 10 | ||
1458 | + int size = frame_size + 1; | ||
1459 | + if (aac_packet_type == SrsCodecAudioAAC) { | ||
1460 | + size += 1; | ||
1461 | + } | ||
1462 | + char* data = new char[size]; | ||
1463 | + char* p = data; | ||
1464 | + | ||
1465 | + u_int8_t audio_header = sound_type & 0x01; | ||
1466 | + audio_header |= (sound_size << 1) & 0x02; | ||
1467 | + audio_header |= (sound_rate << 2) & 0x0c; | ||
1468 | + audio_header |= (sound_format << 4) & 0xf0; | ||
1469 | + | ||
1470 | + *p++ = audio_header; | ||
1471 | + | ||
1472 | + if (aac_packet_type == SrsCodecAudioAAC) { | ||
1473 | + *p++ = aac_packet_type; | ||
1474 | + } | ||
1475 | + | ||
1476 | + memcpy(p, frame, frame_size); | ||
1477 | + | ||
1478 | + return srs_write_packet(context, SRS_RTMP_TYPE_AUDIO, timestamp, data, size); | ||
1479 | +} | ||
1480 | + | ||
1481 | +/** | ||
1442 | * write h264 packet, with rtmp header. | 1482 | * write h264 packet, with rtmp header. |
1443 | * @param frame_type, SrsCodecVideoAVCFrameKeyFrame or SrsCodecVideoAVCFrameInterFrame. | 1483 | * @param frame_type, SrsCodecVideoAVCFrameKeyFrame or SrsCodecVideoAVCFrameInterFrame. |
1444 | * @param avc_packet_type, SrsCodecVideoAVCTypeSequenceHeader or SrsCodecVideoAVCTypeNALU. | 1484 | * @param avc_packet_type, SrsCodecVideoAVCTypeSequenceHeader or SrsCodecVideoAVCTypeNALU. |
@@ -1458,7 +1498,6 @@ int __srs_write_h264_packet(Context* context, | @@ -1458,7 +1498,6 @@ int __srs_write_h264_packet(Context* context, | ||
1458 | // @see: E.4.3 Video Tags, video_file_format_spec_v10_1.pdf, page 78 | 1498 | // @see: E.4.3 Video Tags, video_file_format_spec_v10_1.pdf, page 78 |
1459 | int size = h264_raw_size + 5; | 1499 | int size = h264_raw_size + 5; |
1460 | char* data = new char[size]; | 1500 | char* data = new char[size]; |
1461 | - memcpy(data + 5, h264_raw_data, h264_raw_size); | ||
1462 | char* p = data; | 1501 | char* p = data; |
1463 | 1502 | ||
1464 | // @see: E.4.3 Video Tags, video_file_format_spec_v10_1.pdf, page 78 | 1503 | // @see: E.4.3 Video Tags, video_file_format_spec_v10_1.pdf, page 78 |
@@ -1480,6 +1519,9 @@ int __srs_write_h264_packet(Context* context, | @@ -1480,6 +1519,9 @@ int __srs_write_h264_packet(Context* context, | ||
1480 | *p++ = pp[1]; | 1519 | *p++ = pp[1]; |
1481 | *p++ = pp[0]; | 1520 | *p++ = pp[0]; |
1482 | 1521 | ||
1522 | + // h.264 raw data. | ||
1523 | + memcpy(p, h264_raw_data, h264_raw_size); | ||
1524 | + | ||
1483 | return srs_write_packet(context, SRS_RTMP_TYPE_VIDEO, timestamp, data, size); | 1525 | return srs_write_packet(context, SRS_RTMP_TYPE_VIDEO, timestamp, data, size); |
1484 | } | 1526 | } |
1485 | 1527 |
@@ -463,6 +463,64 @@ extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize); | @@ -463,6 +463,64 @@ extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize); | ||
463 | 463 | ||
464 | /************************************************************* | 464 | /************************************************************* |
465 | ************************************************************** | 465 | ************************************************************** |
466 | +* audio raw codec | ||
467 | +************************************************************** | ||
468 | +*************************************************************/ | ||
469 | +/** | ||
470 | +* write an audio raw frame to srs. | ||
471 | +* not similar to h.264 video, the audio never aggregated, always | ||
472 | +* encoded one frame by one, so this api is used to write a frame. | ||
473 | +* | ||
474 | +* @param sound_format Format of SoundData. The following values are defined: | ||
475 | +* 0 = Linear PCM, platform endian | ||
476 | +* 1 = ADPCM | ||
477 | +* 2 = MP3 | ||
478 | +* 3 = Linear PCM, little endian | ||
479 | +* 4 = Nellymoser 16 kHz mono | ||
480 | +* 5 = Nellymoser 8 kHz mono | ||
481 | +* 6 = Nellymoser | ||
482 | +* 7 = G.711 A-law logarithmic PCM | ||
483 | +* 8 = G.711 mu-law logarithmic PCM | ||
484 | +* 9 = reserved | ||
485 | +* 10 = AAC | ||
486 | +* 11 = Speex | ||
487 | +* 14 = MP3 8 kHz | ||
488 | +* 15 = Device-specific sound | ||
489 | +* Formats 7, 8, 14, and 15 are reserved. | ||
490 | +* AAC is supported in Flash Player 9,0,115,0 and higher. | ||
491 | +* Speex is supported in Flash Player 10 and higher. | ||
492 | +* @param sound_rate Sampling rate. The following values are defined: | ||
493 | +* 0 = 5.5 kHz | ||
494 | +* 1 = 11 kHz | ||
495 | +* 2 = 22 kHz | ||
496 | +* 3 = 44 kHz | ||
497 | +* @param sound_size Size of each audio sample. This parameter only pertains to | ||
498 | +* uncompressed formats. Compressed formats always decode | ||
499 | +* to 16 bits internally. | ||
500 | +* 0 = 8-bit samples | ||
501 | +* 1 = 16-bit samples | ||
502 | +* @param sound_type Mono or stereo sound | ||
503 | +* 0 = Mono sound | ||
504 | +* 1 = Stereo sound | ||
505 | +* @param aac_packet_type The following values are defined: | ||
506 | +* 0 = AAC sequence header | ||
507 | +* 1 = AAC raw | ||
508 | +* @param timestamp The timestamp of audio. | ||
509 | +* | ||
510 | +* @remark Ignore aac_packet_type if not aac(sound_format!=10). | ||
511 | +* | ||
512 | +* @see https://github.com/winlinvip/simple-rtmp-server/issues/212 | ||
513 | +* @see E.4.2.1 AUDIODATA of video_file_format_spec_v10_1.pdf | ||
514 | +* | ||
515 | +* @return 0, success; otherswise, failed. | ||
516 | +*/ | ||
517 | +extern int srs_audio_write_raw_frame(srs_rtmp_t rtmp, | ||
518 | + char sound_format, char sound_rate, char sound_size, char sound_type, | ||
519 | + char aac_packet_type, char* frame, int frame_size, u_int32_t timestamp | ||
520 | +); | ||
521 | + | ||
522 | +/************************************************************* | ||
523 | +************************************************************** | ||
466 | * h264 raw codec | 524 | * h264 raw codec |
467 | ************************************************************** | 525 | ************************************************************** |
468 | *************************************************************/ | 526 | *************************************************************/ |
@@ -474,7 +532,7 @@ typedef int srs_h264_bool; | @@ -474,7 +532,7 @@ typedef int srs_h264_bool; | ||
474 | * each frame prefixed h.264 annexb header, by N[00] 00 00 01, where N>=0, | 532 | * each frame prefixed h.264 annexb header, by N[00] 00 00 01, where N>=0, |
475 | * for instance, frame = header(00 00 00 01) + payload(67 42 80 29 95 A0 14 01 6E 40) | 533 | * for instance, frame = header(00 00 00 01) + payload(67 42 80 29 95 A0 14 01 6E 40) |
476 | * about annexb, @see H.264-AVC-ISO_IEC_14496-10.pdf, page 211. | 534 | * about annexb, @see H.264-AVC-ISO_IEC_14496-10.pdf, page 211. |
477 | -* @paam frames_size the size of h264 raw data. | 535 | +* @param frames_size the size of h264 raw data. |
478 | * assert frames_size > 0, at least has 1 bytes header. | 536 | * assert frames_size > 0, at least has 1 bytes header. |
479 | * @param dts the dts of h.264 raw data. | 537 | * @param dts the dts of h.264 raw data. |
480 | * @param pts the pts of h.264 raw data. | 538 | * @param pts the pts of h.264 raw data. |
@@ -128,6 +128,7 @@ file | @@ -128,6 +128,7 @@ file | ||
128 | ..\utest\srs_utest_reload.hpp, | 128 | ..\utest\srs_utest_reload.hpp, |
129 | ..\utest\srs_utest_reload.cpp, | 129 | ..\utest\srs_utest_reload.cpp, |
130 | research readonly separator, | 130 | research readonly separator, |
131 | + ..\..\research\librtmp\srs_audio_raw_publish.c, | ||
131 | ..\..\research\librtmp\srs_bandwidth_check.c, | 132 | ..\..\research\librtmp\srs_bandwidth_check.c, |
132 | ..\..\research\librtmp\srs_detect_rtmp.c, | 133 | ..\..\research\librtmp\srs_detect_rtmp.c, |
133 | ..\..\research\librtmp\srs_flv_injecter.c, | 134 | ..\..\research\librtmp\srs_flv_injecter.c, |
-
请 注册 或 登录 后发表评论