正在显示
4 个修改的文件
包含
355 行增加
和
32 行删除
| @@ -35,7 +35,7 @@ int main(int argc, char** argv) | @@ -35,7 +35,7 @@ int main(int argc, char** argv) | ||
| 35 | srs_rtmp_t rtmp; | 35 | srs_rtmp_t rtmp; |
| 36 | 36 | ||
| 37 | // time | 37 | // time |
| 38 | - int64_t time_startup = srs_utils_get_time_ms(); | 38 | + int64_t time_startup = srs_utils_time_ms(); |
| 39 | int64_t time_dns_resolve = 0; | 39 | int64_t time_dns_resolve = 0; |
| 40 | int64_t time_socket_connect = 0; | 40 | int64_t time_socket_connect = 0; |
| 41 | int64_t time_play_stream = 0; | 41 | int64_t time_play_stream = 0; |
| @@ -95,14 +95,14 @@ int main(int argc, char** argv) | @@ -95,14 +95,14 @@ int main(int argc, char** argv) | ||
| 95 | goto rtmp_destroy; | 95 | goto rtmp_destroy; |
| 96 | } | 96 | } |
| 97 | srs_human_trace("dns resolve success"); | 97 | srs_human_trace("dns resolve success"); |
| 98 | - time_dns_resolve = srs_utils_get_time_ms(); | 98 | + time_dns_resolve = srs_utils_time_ms(); |
| 99 | 99 | ||
| 100 | if ((ret = __srs_rtmp_connect_server(rtmp)) != 0) { | 100 | if ((ret = __srs_rtmp_connect_server(rtmp)) != 0) { |
| 101 | srs_human_trace("socket connect failed. ret=%d", ret); | 101 | srs_human_trace("socket connect failed. ret=%d", ret); |
| 102 | goto rtmp_destroy; | 102 | goto rtmp_destroy; |
| 103 | } | 103 | } |
| 104 | srs_human_trace("socket connect success"); | 104 | srs_human_trace("socket connect success"); |
| 105 | - time_socket_connect = srs_utils_get_time_ms(); | 105 | + time_socket_connect = srs_utils_time_ms(); |
| 106 | 106 | ||
| 107 | if ((ret = __srs_rtmp_do_simple_handshake(rtmp)) != 0) { | 107 | if ((ret = __srs_rtmp_do_simple_handshake(rtmp)) != 0) { |
| 108 | srs_human_trace("do simple handshake failed. ret=%d", ret); | 108 | srs_human_trace("do simple handshake failed. ret=%d", ret); |
| @@ -121,7 +121,7 @@ int main(int argc, char** argv) | @@ -121,7 +121,7 @@ int main(int argc, char** argv) | ||
| 121 | goto rtmp_destroy; | 121 | goto rtmp_destroy; |
| 122 | } | 122 | } |
| 123 | srs_human_trace("play stream success"); | 123 | srs_human_trace("play stream success"); |
| 124 | - time_play_stream = srs_utils_get_time_ms(); | 124 | + time_play_stream = srs_utils_time_ms(); |
| 125 | 125 | ||
| 126 | for (;;) { | 126 | for (;;) { |
| 127 | if ((ret = srs_rtmp_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) { | 127 | if ((ret = srs_rtmp_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) { |
| @@ -133,7 +133,7 @@ int main(int argc, char** argv) | @@ -133,7 +133,7 @@ int main(int argc, char** argv) | ||
| 133 | 133 | ||
| 134 | if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) { | 134 | if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) { |
| 135 | if (time_first_packet <= 0) { | 135 | if (time_first_packet <= 0) { |
| 136 | - time_first_packet = srs_utils_get_time_ms(); | 136 | + time_first_packet = srs_utils_time_ms(); |
| 137 | } | 137 | } |
| 138 | if (basetime <= 0) { | 138 | if (basetime <= 0) { |
| 139 | basetime = timestamp; | 139 | basetime = timestamp; |
| @@ -142,7 +142,7 @@ int main(int argc, char** argv) | @@ -142,7 +142,7 @@ int main(int argc, char** argv) | ||
| 142 | 142 | ||
| 143 | free(data); | 143 | free(data); |
| 144 | 144 | ||
| 145 | - if (srs_utils_get_time_ms() - time_startup > timeout * 1000) { | 145 | + if (srs_utils_time_ms() - time_startup > timeout * 1000) { |
| 146 | srs_human_trace("timeout, terminate."); | 146 | srs_human_trace("timeout, terminate."); |
| 147 | goto rtmp_destroy; | 147 | goto rtmp_destroy; |
| 148 | } | 148 | } |
| @@ -154,11 +154,11 @@ int main(int argc, char** argv) | @@ -154,11 +154,11 @@ int main(int argc, char** argv) | ||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | rtmp_destroy: | 156 | rtmp_destroy: |
| 157 | - bytes_nsend = srs_utils_get_send_bytes(rtmp); | ||
| 158 | - bytes_nrecv = srs_utils_get_recv_bytes(rtmp); | 157 | + bytes_nsend = srs_utils_send_bytes(rtmp); |
| 158 | + bytes_nrecv = srs_utils_recv_bytes(rtmp); | ||
| 159 | 159 | ||
| 160 | srs_rtmp_destroy(rtmp); | 160 | srs_rtmp_destroy(rtmp); |
| 161 | - time_cleanup = srs_utils_get_time_ms(); | 161 | + time_cleanup = srs_utils_time_ms(); |
| 162 | time_duration = (int)(time_cleanup - time_startup); | 162 | time_duration = (int)(time_cleanup - time_startup); |
| 163 | 163 | ||
| 164 | // print result to stderr. | 164 | // print result to stderr. |
| @@ -48,7 +48,7 @@ int main(int argc, char** argv) | @@ -48,7 +48,7 @@ int main(int argc, char** argv) | ||
| 48 | int ret = 0; | 48 | int ret = 0; |
| 49 | 49 | ||
| 50 | // main function | 50 | // main function |
| 51 | - tools_main_entrance_startup_time = srs_utils_get_time_ms(); | 51 | + tools_main_entrance_startup_time = srs_utils_time_ms(); |
| 52 | 52 | ||
| 53 | // user option parse index. | 53 | // user option parse index. |
| 54 | int opt = 0; | 54 | int opt = 0; |
| @@ -215,7 +215,7 @@ int connect_oc(srs_rtmp_t ortmp) | @@ -215,7 +215,7 @@ int connect_oc(srs_rtmp_t ortmp) | ||
| 215 | int64_t re_create() | 215 | int64_t re_create() |
| 216 | { | 216 | { |
| 217 | // if not very precise, we can directly use this as re. | 217 | // if not very precise, we can directly use this as re. |
| 218 | - int64_t re = srs_utils_get_time_ms(); | 218 | + int64_t re = srs_utils_time_ms(); |
| 219 | 219 | ||
| 220 | // use the starttime to get the deviation | 220 | // use the starttime to get the deviation |
| 221 | int64_t deviation = re - tools_main_entrance_startup_time; | 221 | int64_t deviation = re - tools_main_entrance_startup_time; |
| @@ -236,7 +236,7 @@ int64_t re_create() | @@ -236,7 +236,7 @@ int64_t re_create() | ||
| 236 | void re_update(int64_t re, int32_t starttime, u_int32_t time) | 236 | void re_update(int64_t re, int32_t starttime, u_int32_t time) |
| 237 | { | 237 | { |
| 238 | // send by pulse algorithm. | 238 | // send by pulse algorithm. |
| 239 | - int64_t now = srs_utils_get_time_ms(); | 239 | + int64_t now = srs_utils_time_ms(); |
| 240 | int64_t diff = time - starttime - (now -re); | 240 | int64_t diff = time - starttime - (now -re); |
| 241 | if (diff > RE_PULSE_MS) { | 241 | if (diff > RE_PULSE_MS) { |
| 242 | usleep(diff * 1000); | 242 | usleep(diff * 1000); |
| @@ -246,7 +246,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time) | @@ -246,7 +246,7 @@ void re_cleanup(int64_t re, int32_t starttime, u_int32_t time) | ||
| 246 | { | 246 | { |
| 247 | // for the last pulse, always sleep. | 247 | // for the last pulse, always sleep. |
| 248 | // for the virtual live encoder long time publishing. | 248 | // for the virtual live encoder long time publishing. |
| 249 | - int64_t now = srs_utils_get_time_ms(); | 249 | + int64_t now = srs_utils_time_ms(); |
| 250 | int64_t diff = time - starttime - (now -re); | 250 | int64_t diff = time - starttime - (now -re); |
| 251 | if (diff > 0) { | 251 | if (diff > 0) { |
| 252 | srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms", | 252 | srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms", |
| @@ -1712,20 +1712,20 @@ void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value) | @@ -1712,20 +1712,20 @@ void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value) | ||
| 1712 | obj->append(any); | 1712 | obj->append(any); |
| 1713 | } | 1713 | } |
| 1714 | 1714 | ||
| 1715 | -int64_t srs_utils_get_time_ms() | 1715 | +int64_t srs_utils_time_ms() |
| 1716 | { | 1716 | { |
| 1717 | srs_update_system_time_ms(); | 1717 | srs_update_system_time_ms(); |
| 1718 | return srs_get_system_time_ms(); | 1718 | return srs_get_system_time_ms(); |
| 1719 | } | 1719 | } |
| 1720 | 1720 | ||
| 1721 | -int64_t srs_utils_get_send_bytes(srs_rtmp_t rtmp) | 1721 | +int64_t srs_utils_send_bytes(srs_rtmp_t rtmp) |
| 1722 | { | 1722 | { |
| 1723 | srs_assert(rtmp != NULL); | 1723 | srs_assert(rtmp != NULL); |
| 1724 | Context* context = (Context*)rtmp; | 1724 | Context* context = (Context*)rtmp; |
| 1725 | return context->rtmp->get_send_bytes(); | 1725 | return context->rtmp->get_send_bytes(); |
| 1726 | } | 1726 | } |
| 1727 | 1727 | ||
| 1728 | -int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp) | 1728 | +int64_t srs_utils_recv_bytes(srs_rtmp_t rtmp) |
| 1729 | { | 1729 | { |
| 1730 | srs_assert(rtmp != NULL); | 1730 | srs_assert(rtmp != NULL); |
| 1731 | Context* context = (Context*)rtmp; | 1731 | Context* context = (Context*)rtmp; |
| @@ -1773,7 +1773,7 @@ int srs_utils_parse_timestamp( | @@ -1773,7 +1773,7 @@ int srs_utils_parse_timestamp( | ||
| 1773 | return ret; | 1773 | return ret; |
| 1774 | } | 1774 | } |
| 1775 | 1775 | ||
| 1776 | -char srs_utils_get_flv_video_codec_id(char* data, int size) | 1776 | +char srs_utils_flv_video_codec_id(char* data, int size) |
| 1777 | { | 1777 | { |
| 1778 | if (size < 1) { | 1778 | if (size < 1) { |
| 1779 | return 0; | 1779 | return 0; |
| @@ -1785,7 +1785,7 @@ char srs_utils_get_flv_video_codec_id(char* data, int size) | @@ -1785,7 +1785,7 @@ char srs_utils_get_flv_video_codec_id(char* data, int size) | ||
| 1785 | return codec_id; | 1785 | return codec_id; |
| 1786 | } | 1786 | } |
| 1787 | 1787 | ||
| 1788 | -char srs_utils_get_flv_video_avc_packet_type(char* data, int size) | 1788 | +char srs_utils_flv_video_avc_packet_type(char* data, int size) |
| 1789 | { | 1789 | { |
| 1790 | if (size < 2) { | 1790 | if (size < 2) { |
| 1791 | return -1; | 1791 | return -1; |
| @@ -1804,7 +1804,7 @@ char srs_utils_get_flv_video_avc_packet_type(char* data, int size) | @@ -1804,7 +1804,7 @@ char srs_utils_get_flv_video_avc_packet_type(char* data, int size) | ||
| 1804 | return avc_packet_type; | 1804 | return avc_packet_type; |
| 1805 | } | 1805 | } |
| 1806 | 1806 | ||
| 1807 | -char srs_utils_get_flv_video_frame_type(char* data, int size) | 1807 | +char srs_utils_flv_video_frame_type(char* data, int size) |
| 1808 | { | 1808 | { |
| 1809 | if (size < 1) { | 1809 | if (size < 1) { |
| 1810 | return -1; | 1810 | return -1; |
| @@ -1823,6 +1823,85 @@ char srs_utils_get_flv_video_frame_type(char* data, int size) | @@ -1823,6 +1823,85 @@ char srs_utils_get_flv_video_frame_type(char* data, int size) | ||
| 1823 | return frame_type; | 1823 | return frame_type; |
| 1824 | } | 1824 | } |
| 1825 | 1825 | ||
| 1826 | +char srs_utils_flv_audio_sound_format(char* data, int size) | ||
| 1827 | +{ | ||
| 1828 | + if (size < 1) { | ||
| 1829 | + return -1; | ||
| 1830 | + } | ||
| 1831 | + | ||
| 1832 | + u_int8_t sound_format = data[0]; | ||
| 1833 | + sound_format = (sound_format >> 4) & 0x0f; | ||
| 1834 | + if (sound_format > 15 || sound_format == 12 || sound_format == 13) { | ||
| 1835 | + return -1; | ||
| 1836 | + } | ||
| 1837 | + | ||
| 1838 | + return sound_format; | ||
| 1839 | +} | ||
| 1840 | + | ||
| 1841 | +char srs_utils_flv_audio_sound_rate(char* data, int size) | ||
| 1842 | +{ | ||
| 1843 | + if (size < 1) { | ||
| 1844 | + return -1; | ||
| 1845 | + } | ||
| 1846 | + | ||
| 1847 | + u_int8_t sound_rate = data[0]; | ||
| 1848 | + sound_rate = (sound_rate >> 2) & 0x03; | ||
| 1849 | + if (sound_rate > 3) { | ||
| 1850 | + return -1; | ||
| 1851 | + } | ||
| 1852 | + | ||
| 1853 | + return sound_rate; | ||
| 1854 | +} | ||
| 1855 | + | ||
| 1856 | +char srs_utils_flv_audio_sound_size(char* data, int size) | ||
| 1857 | +{ | ||
| 1858 | + if (size < 1) { | ||
| 1859 | + return -1; | ||
| 1860 | + } | ||
| 1861 | + | ||
| 1862 | + u_int8_t sound_size = data[0]; | ||
| 1863 | + sound_size = (sound_size >> 1) & 0x01; | ||
| 1864 | + if (sound_size > 1) { | ||
| 1865 | + return -1; | ||
| 1866 | + } | ||
| 1867 | + | ||
| 1868 | + return sound_size; | ||
| 1869 | +} | ||
| 1870 | + | ||
| 1871 | +char srs_utils_flv_audio_sound_type(char* data, int size) | ||
| 1872 | +{ | ||
| 1873 | + if (size < 1) { | ||
| 1874 | + return -1; | ||
| 1875 | + } | ||
| 1876 | + | ||
| 1877 | + u_int8_t sound_type = data[0]; | ||
| 1878 | + sound_type = sound_type & 0x01; | ||
| 1879 | + if (sound_type > 1) { | ||
| 1880 | + return -1; | ||
| 1881 | + } | ||
| 1882 | + | ||
| 1883 | + return sound_type; | ||
| 1884 | +} | ||
| 1885 | + | ||
| 1886 | +char srs_utils_flv_audio_aac_packet_type(char* data, int size) | ||
| 1887 | +{ | ||
| 1888 | + if (size < 2) { | ||
| 1889 | + return -1; | ||
| 1890 | + } | ||
| 1891 | + | ||
| 1892 | + if (srs_utils_flv_audio_sound_format(data, size) != 10) { | ||
| 1893 | + return -1; | ||
| 1894 | + } | ||
| 1895 | + | ||
| 1896 | + u_int8_t aac_packet_type = data[1]; | ||
| 1897 | + aac_packet_type = aac_packet_type; | ||
| 1898 | + if (aac_packet_type > 1) { | ||
| 1899 | + return -1; | ||
| 1900 | + } | ||
| 1901 | + | ||
| 1902 | + return aac_packet_type; | ||
| 1903 | +} | ||
| 1904 | + | ||
| 1826 | char* srs_human_amf0_print(srs_amf0_t amf0, char** pdata, int* psize) | 1905 | char* srs_human_amf0_print(srs_amf0_t amf0, char** pdata, int* psize) |
| 1827 | { | 1906 | { |
| 1828 | if (!amf0) { | 1907 | if (!amf0) { |
| @@ -1876,7 +1955,7 @@ const char* srs_human_flv_video_codec_id2string(char codec_id) | @@ -1876,7 +1955,7 @@ const char* srs_human_flv_video_codec_id2string(char codec_id) | ||
| 1876 | 1955 | ||
| 1877 | const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_type) | 1956 | const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_type) |
| 1878 | { | 1957 | { |
| 1879 | - static const char* sps_pps = "SpsPps"; | 1958 | + static const char* sps_pps = "SH"; |
| 1880 | static const char* nalu = "Nalu"; | 1959 | static const char* nalu = "Nalu"; |
| 1881 | static const char* sps_pps_end = "SpsPpsEnd"; | 1960 | static const char* sps_pps_end = "SpsPpsEnd"; |
| 1882 | static const char* unknown = "Unknown"; | 1961 | static const char* unknown = "Unknown"; |
| @@ -1912,6 +1991,109 @@ const char* srs_human_flv_video_frame_type2string(char frame_type) | @@ -1912,6 +1991,109 @@ const char* srs_human_flv_video_frame_type2string(char frame_type) | ||
| 1912 | return unknown; | 1991 | return unknown; |
| 1913 | } | 1992 | } |
| 1914 | 1993 | ||
| 1994 | +const char* srs_human_flv_audio_sound_format2string(char sound_format) | ||
| 1995 | +{ | ||
| 1996 | + static const char* linear_pcm = "LinearPCM"; | ||
| 1997 | + static const char* ad_pcm = "ADPCM"; | ||
| 1998 | + static const char* mp3 = "MP3"; | ||
| 1999 | + static const char* linear_pcm_le = "LinearPCMLe"; | ||
| 2000 | + static const char* nellymoser_16khz = "NellymoserKHz16"; | ||
| 2001 | + static const char* nellymoser_8khz = "NellymoserKHz8"; | ||
| 2002 | + static const char* nellymoser = "Nellymoser"; | ||
| 2003 | + static const char* g711_a_pcm = "G711APCM"; | ||
| 2004 | + static const char* g711_mu_pcm = "G711MuPCM"; | ||
| 2005 | + static const char* reserved = "Reserved"; | ||
| 2006 | + static const char* aac = "AAC"; | ||
| 2007 | + static const char* speex = "Speex"; | ||
| 2008 | + static const char* mp3_8khz = "MP3KHz8"; | ||
| 2009 | + static const char* device_specific = "DeviceSpecific"; | ||
| 2010 | + static const char* unknown = "Unknown"; | ||
| 2011 | + | ||
| 2012 | + switch (sound_format) { | ||
| 2013 | + case 0: return linear_pcm; | ||
| 2014 | + case 1: return ad_pcm; | ||
| 2015 | + case 2: return mp3; | ||
| 2016 | + case 3: return linear_pcm_le; | ||
| 2017 | + case 4: return nellymoser_16khz; | ||
| 2018 | + case 5: return nellymoser_8khz; | ||
| 2019 | + case 6: return nellymoser; | ||
| 2020 | + case 7: return g711_a_pcm; | ||
| 2021 | + case 8: return g711_mu_pcm; | ||
| 2022 | + case 9: return reserved; | ||
| 2023 | + case 10: return aac; | ||
| 2024 | + case 11: return speex; | ||
| 2025 | + case 14: return mp3_8khz; | ||
| 2026 | + case 15: return device_specific; | ||
| 2027 | + default: return unknown; | ||
| 2028 | + } | ||
| 2029 | + | ||
| 2030 | + return unknown; | ||
| 2031 | +} | ||
| 2032 | + | ||
| 2033 | +const char* srs_human_flv_audio_sound_rate2string(char sound_rate) | ||
| 2034 | +{ | ||
| 2035 | + static const char* khz_5_5 = "5.5KHz"; | ||
| 2036 | + static const char* khz_11 = "11KHz"; | ||
| 2037 | + static const char* khz_22 = "22KHz"; | ||
| 2038 | + static const char* khz_44 = "44KHz"; | ||
| 2039 | + static const char* unknown = "Unknown"; | ||
| 2040 | + | ||
| 2041 | + switch (sound_rate) { | ||
| 2042 | + case 0: return khz_5_5; | ||
| 2043 | + case 1: return khz_11; | ||
| 2044 | + case 2: return khz_22; | ||
| 2045 | + case 3: return khz_44; | ||
| 2046 | + default: return unknown; | ||
| 2047 | + } | ||
| 2048 | + | ||
| 2049 | + return unknown; | ||
| 2050 | +} | ||
| 2051 | + | ||
| 2052 | +const char* srs_human_flv_audio_sound_size2string(char sound_size) | ||
| 2053 | +{ | ||
| 2054 | + static const char* bit_8 = "8bit"; | ||
| 2055 | + static const char* bit_16 = "16bit"; | ||
| 2056 | + static const char* unknown = "Unknown"; | ||
| 2057 | + | ||
| 2058 | + switch (sound_size) { | ||
| 2059 | + case 0: return bit_8; | ||
| 2060 | + case 1: return bit_16; | ||
| 2061 | + default: return unknown; | ||
| 2062 | + } | ||
| 2063 | + | ||
| 2064 | + return unknown; | ||
| 2065 | +} | ||
| 2066 | + | ||
| 2067 | +const char* srs_human_flv_audio_sound_type2string(char sound_type) | ||
| 2068 | +{ | ||
| 2069 | + static const char* mono = "Mono"; | ||
| 2070 | + static const char* stereo = "Stereo"; | ||
| 2071 | + static const char* unknown = "Unknown"; | ||
| 2072 | + | ||
| 2073 | + switch (sound_type) { | ||
| 2074 | + case 0: return mono; | ||
| 2075 | + case 1: return stereo; | ||
| 2076 | + default: return unknown; | ||
| 2077 | + } | ||
| 2078 | + | ||
| 2079 | + return unknown; | ||
| 2080 | +} | ||
| 2081 | + | ||
| 2082 | +const char* srs_human_flv_audio_aac_packet_type2string(char aac_packet_type) | ||
| 2083 | +{ | ||
| 2084 | + static const char* sps_pps = "SH"; | ||
| 2085 | + static const char* raw = "Raw"; | ||
| 2086 | + static const char* unknown = "Unknown"; | ||
| 2087 | + | ||
| 2088 | + switch (aac_packet_type) { | ||
| 2089 | + case 0: return sps_pps; | ||
| 2090 | + case 1: return raw; | ||
| 2091 | + default: return unknown; | ||
| 2092 | + } | ||
| 2093 | + | ||
| 2094 | + return unknown; | ||
| 2095 | +} | ||
| 2096 | + | ||
| 1915 | int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) | 2097 | int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int size) |
| 1916 | { | 2098 | { |
| 1917 | int ret = ERROR_SUCCESS; | 2099 | int ret = ERROR_SUCCESS; |
| @@ -1924,13 +2106,19 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int | @@ -1924,13 +2106,19 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int | ||
| 1924 | if (type == SRS_RTMP_TYPE_VIDEO) { | 2106 | if (type == SRS_RTMP_TYPE_VIDEO) { |
| 1925 | srs_human_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)", | 2107 | srs_human_trace("Video packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s)", |
| 1926 | srs_human_flv_tag_type2string(type), timestamp, pts, size, | 2108 | srs_human_flv_tag_type2string(type), timestamp, pts, size, |
| 1927 | - srs_human_flv_video_codec_id2string(srs_utils_get_flv_video_codec_id(data, size)), | ||
| 1928 | - srs_human_flv_video_avc_packet_type2string(srs_utils_get_flv_video_avc_packet_type(data, size)), | ||
| 1929 | - srs_human_flv_video_frame_type2string(srs_utils_get_flv_video_frame_type(data, size)) | 2109 | + srs_human_flv_video_codec_id2string(srs_utils_flv_video_codec_id(data, size)), |
| 2110 | + srs_human_flv_video_avc_packet_type2string(srs_utils_flv_video_avc_packet_type(data, size)), | ||
| 2111 | + srs_human_flv_video_frame_type2string(srs_utils_flv_video_frame_type(data, size)) | ||
| 1930 | ); | 2112 | ); |
| 1931 | } else if (type == SRS_RTMP_TYPE_AUDIO) { | 2113 | } else if (type == SRS_RTMP_TYPE_AUDIO) { |
| 1932 | - srs_human_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d", | ||
| 1933 | - srs_human_flv_tag_type2string(type), timestamp, pts, size); | 2114 | + srs_human_trace("Audio packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s,%s,%s)", |
| 2115 | + srs_human_flv_tag_type2string(type), timestamp, pts, size, | ||
| 2116 | + srs_human_flv_audio_sound_format2string(srs_utils_flv_audio_sound_format(data, size)), | ||
| 2117 | + srs_human_flv_audio_sound_rate2string(srs_utils_flv_audio_sound_rate(data, size)), | ||
| 2118 | + srs_human_flv_audio_sound_size2string(srs_utils_flv_audio_sound_size(data, size)), | ||
| 2119 | + srs_human_flv_audio_sound_type2string(srs_utils_flv_audio_sound_type(data, size)), | ||
| 2120 | + srs_human_flv_audio_aac_packet_type2string(srs_utils_flv_audio_aac_packet_type(data, size)) | ||
| 2121 | + ); | ||
| 1934 | } else if (type == SRS_RTMP_TYPE_SCRIPT) { | 2122 | } else if (type == SRS_RTMP_TYPE_SCRIPT) { |
| 1935 | srs_human_verbose("Data packet type=%s, time=%d, size=%d", | 2123 | srs_human_verbose("Data packet type=%s, time=%d, size=%d", |
| 1936 | srs_human_flv_tag_type2string(type), timestamp, size); | 2124 | srs_human_flv_tag_type2string(type), timestamp, size); |
| @@ -592,17 +592,17 @@ extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value); | @@ -592,17 +592,17 @@ extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value); | ||
| 592 | * get the current system time in ms. | 592 | * get the current system time in ms. |
| 593 | * use gettimeofday() to get system time. | 593 | * use gettimeofday() to get system time. |
| 594 | */ | 594 | */ |
| 595 | -extern int64_t srs_utils_get_time_ms(); | 595 | +extern int64_t srs_utils_time_ms(); |
| 596 | 596 | ||
| 597 | /** | 597 | /** |
| 598 | * get the send bytes. | 598 | * get the send bytes. |
| 599 | */ | 599 | */ |
| 600 | -extern int64_t srs_utils_get_send_bytes(srs_rtmp_t rtmp); | 600 | +extern int64_t srs_utils_send_bytes(srs_rtmp_t rtmp); |
| 601 | 601 | ||
| 602 | /** | 602 | /** |
| 603 | * get the recv bytes. | 603 | * get the recv bytes. |
| 604 | */ | 604 | */ |
| 605 | -extern int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp); | 605 | +extern int64_t srs_utils_recv_bytes(srs_rtmp_t rtmp); |
| 606 | 606 | ||
| 607 | /** | 607 | /** |
| 608 | * parse the dts and pts by time in header and data in tag, | 608 | * parse the dts and pts by time in header and data in tag, |
| @@ -635,7 +635,7 @@ extern int srs_utils_parse_timestamp( | @@ -635,7 +635,7 @@ extern int srs_utils_parse_timestamp( | ||
| 635 | * 7 = AVC | 635 | * 7 = AVC |
| 636 | * @return the code id. 0 for error. | 636 | * @return the code id. 0 for error. |
| 637 | */ | 637 | */ |
| 638 | -extern char srs_utils_get_flv_video_codec_id(char* data, int size); | 638 | +extern char srs_utils_flv_video_codec_id(char* data, int size); |
| 639 | 639 | ||
| 640 | /** | 640 | /** |
| 641 | * get the AVCPacketType of video tag. | 641 | * get the AVCPacketType of video tag. |
| @@ -646,7 +646,7 @@ extern char srs_utils_get_flv_video_codec_id(char* data, int size); | @@ -646,7 +646,7 @@ extern char srs_utils_get_flv_video_codec_id(char* data, int size); | ||
| 646 | * not required or supported) | 646 | * not required or supported) |
| 647 | * @return the avc packet type. -1(0xff) for error. | 647 | * @return the avc packet type. -1(0xff) for error. |
| 648 | */ | 648 | */ |
| 649 | -extern char srs_utils_get_flv_video_avc_packet_type(char* data, int size); | 649 | +extern char srs_utils_flv_video_avc_packet_type(char* data, int size); |
| 650 | 650 | ||
| 651 | /** | 651 | /** |
| 652 | * get the FrameType of video tag. | 652 | * get the FrameType of video tag. |
| @@ -658,7 +658,71 @@ extern char srs_utils_get_flv_video_avc_packet_type(char* data, int size); | @@ -658,7 +658,71 @@ extern char srs_utils_get_flv_video_avc_packet_type(char* data, int size); | ||
| 658 | * 5 = video info/command frame | 658 | * 5 = video info/command frame |
| 659 | * @return the frame type. 0 for error. | 659 | * @return the frame type. 0 for error. |
| 660 | */ | 660 | */ |
| 661 | -extern char srs_utils_get_flv_video_frame_type(char* data, int size); | 661 | +extern char srs_utils_flv_video_frame_type(char* data, int size); |
| 662 | + | ||
| 663 | +/** | ||
| 664 | +* get the SoundFormat of audio tag. | ||
| 665 | +* Format of SoundData. The following values are defined: | ||
| 666 | +* 0 = Linear PCM, platform endian | ||
| 667 | +* 1 = ADPCM | ||
| 668 | +* 2 = MP3 | ||
| 669 | +* 3 = Linear PCM, little endian | ||
| 670 | +* 4 = Nellymoser 16 kHz mono | ||
| 671 | +* 5 = Nellymoser 8 kHz mono | ||
| 672 | +* 6 = Nellymoser | ||
| 673 | +* 7 = G.711 A-law logarithmic PCM | ||
| 674 | +* 8 = G.711 mu-law logarithmic PCM | ||
| 675 | +* 9 = reserved | ||
| 676 | +* 10 = AAC | ||
| 677 | +* 11 = Speex | ||
| 678 | +* 14 = MP3 8 kHz | ||
| 679 | +* 15 = Device-specific sound | ||
| 680 | +* Formats 7, 8, 14, and 15 are reserved. | ||
| 681 | +* AAC is supported in Flash Player 9,0,115,0 and higher. | ||
| 682 | +* Speex is supported in Flash Player 10 and higher. | ||
| 683 | +* @return the sound format. -1(0xff) for error. | ||
| 684 | +*/ | ||
| 685 | +extern char srs_utils_flv_audio_sound_format(char* data, int size); | ||
| 686 | + | ||
| 687 | +/** | ||
| 688 | +* get the SoundRate of audio tag. | ||
| 689 | +* Sampling rate. The following values are defined: | ||
| 690 | +* 0 = 5.5 kHz | ||
| 691 | +* 1 = 11 kHz | ||
| 692 | +* 2 = 22 kHz | ||
| 693 | +* 3 = 44 kHz | ||
| 694 | +* @return the sound rate. -1(0xff) for error. | ||
| 695 | +*/ | ||
| 696 | +extern char srs_utils_flv_audio_sound_rate(char* data, int size); | ||
| 697 | + | ||
| 698 | +/** | ||
| 699 | +* get the SoundSize of audio tag. | ||
| 700 | +* Size of each audio sample. This parameter only pertains to | ||
| 701 | +* uncompressed formats. Compressed formats always decode | ||
| 702 | +* to 16 bits internally. | ||
| 703 | +* 0 = 8-bit samples | ||
| 704 | +* 1 = 16-bit samples | ||
| 705 | +* @return the sound size. -1(0xff) for error. | ||
| 706 | +*/ | ||
| 707 | +extern char srs_utils_flv_audio_sound_size(char* data, int size); | ||
| 708 | + | ||
| 709 | +/** | ||
| 710 | +* get the SoundType of audio tag. | ||
| 711 | +* Mono or stereo sound | ||
| 712 | +* 0 = Mono sound | ||
| 713 | +* 1 = Stereo sound | ||
| 714 | +* @return the sound type. -1(0xff) for error. | ||
| 715 | +*/ | ||
| 716 | +extern char srs_utils_flv_audio_sound_type(char* data, int size); | ||
| 717 | + | ||
| 718 | +/** | ||
| 719 | +* get the AACPacketType of audio tag. | ||
| 720 | +* The following values are defined: | ||
| 721 | +* 0 = AAC sequence header | ||
| 722 | +* 1 = AAC raw | ||
| 723 | +* @return the aac packet type. -1(0xff) for error. | ||
| 724 | +*/ | ||
| 725 | +extern char srs_utils_flv_audio_aac_packet_type(char* data, int size); | ||
| 662 | 726 | ||
| 663 | /************************************************************* | 727 | /************************************************************* |
| 664 | ************************************************************** | 728 | ************************************************************** |
| @@ -699,7 +763,7 @@ extern const char* srs_human_flv_video_codec_id2string(char codec_id); | @@ -699,7 +763,7 @@ extern const char* srs_human_flv_video_codec_id2string(char codec_id); | ||
| 699 | 763 | ||
| 700 | /** | 764 | /** |
| 701 | * get the avc packet type string. | 765 | * get the avc packet type string. |
| 702 | -* SpsPps = AVC sequence header | 766 | +* SH = AVC sequence header |
| 703 | * Nalu = AVC NALU | 767 | * Nalu = AVC NALU |
| 704 | * SpsPpsEnd = AVC end of sequence | 768 | * SpsPpsEnd = AVC end of sequence |
| 705 | * otherwise, "Unknown" | 769 | * otherwise, "Unknown" |
| @@ -722,6 +786,77 @@ extern const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_ty | @@ -722,6 +786,77 @@ extern const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_ty | ||
| 722 | extern const char* srs_human_flv_video_frame_type2string(char frame_type); | 786 | extern const char* srs_human_flv_video_frame_type2string(char frame_type); |
| 723 | 787 | ||
| 724 | /** | 788 | /** |
| 789 | +* get the SoundFormat string. | ||
| 790 | +* Format of SoundData. The following values are defined: | ||
| 791 | +* LinearPCM = Linear PCM, platform endian | ||
| 792 | +* ADPCM = ADPCM | ||
| 793 | +* MP3 = MP3 | ||
| 794 | +* LinearPCMLe = Linear PCM, little endian | ||
| 795 | +* NellymoserKHz16 = Nellymoser 16 kHz mono | ||
| 796 | +* NellymoserKHz8 = Nellymoser 8 kHz mono | ||
| 797 | +* Nellymoser = Nellymoser | ||
| 798 | +* G711APCM = G.711 A-law logarithmic PCM | ||
| 799 | +* G711MuPCM = G.711 mu-law logarithmic PCM | ||
| 800 | +* Reserved = reserved | ||
| 801 | +* AAC = AAC | ||
| 802 | +* Speex = Speex | ||
| 803 | +* MP3KHz8 = MP3 8 kHz | ||
| 804 | +* DeviceSpecific = Device-specific sound | ||
| 805 | +* otherwise, "Unknown" | ||
| 806 | +* @remark user never free the return char*, | ||
| 807 | +* it's static shared const string. | ||
| 808 | +*/ | ||
| 809 | +extern const char* srs_human_flv_audio_sound_format2string(char sound_format); | ||
| 810 | + | ||
| 811 | +/** | ||
| 812 | +* get the SoundRate of audio tag. | ||
| 813 | +* Sampling rate. The following values are defined: | ||
| 814 | +* 5.5KHz = 5.5 kHz | ||
| 815 | +* 11KHz = 11 kHz | ||
| 816 | +* 22KHz = 22 kHz | ||
| 817 | +* 44KHz = 44 kHz | ||
| 818 | +* otherwise, "Unknown" | ||
| 819 | +* @remark user never free the return char*, | ||
| 820 | +* it's static shared const string. | ||
| 821 | +*/ | ||
| 822 | +extern const char* srs_human_flv_audio_sound_rate2string(char sound_rate); | ||
| 823 | + | ||
| 824 | +/** | ||
| 825 | +* get the SoundSize of audio tag. | ||
| 826 | +* Size of each audio sample. This parameter only pertains to | ||
| 827 | +* uncompressed formats. Compressed formats always decode | ||
| 828 | +* to 16 bits internally. | ||
| 829 | +* 8bit = 8-bit samples | ||
| 830 | +* 16bit = 16-bit samples | ||
| 831 | +* otherwise, "Unknown" | ||
| 832 | +* @remark user never free the return char*, | ||
| 833 | +* it's static shared const string. | ||
| 834 | +*/ | ||
| 835 | +extern const char* srs_human_flv_audio_sound_size2string(char sound_size); | ||
| 836 | + | ||
| 837 | +/** | ||
| 838 | +* get the SoundType of audio tag. | ||
| 839 | +* Mono or stereo sound | ||
| 840 | +* Mono = Mono sound | ||
| 841 | +* Stereo = Stereo sound | ||
| 842 | +* otherwise, "Unknown" | ||
| 843 | +* @remark user never free the return char*, | ||
| 844 | +* it's static shared const string. | ||
| 845 | +*/ | ||
| 846 | +extern const char* srs_human_flv_audio_sound_type2string(char sound_type); | ||
| 847 | + | ||
| 848 | +/** | ||
| 849 | +* get the AACPacketType of audio tag. | ||
| 850 | +* The following values are defined: | ||
| 851 | +* SH = AAC sequence header | ||
| 852 | +* Raw = AAC raw | ||
| 853 | +* otherwise, "Unknown" | ||
| 854 | +* @remark user never free the return char*, | ||
| 855 | +* it's static shared const string. | ||
| 856 | +*/ | ||
| 857 | +extern const char* srs_human_flv_audio_aac_packet_type2string(char aac_packet_type); | ||
| 858 | + | ||
| 859 | +/** | ||
| 725 | * print the rtmp packet, use srs_human_trace/srs_human_verbose for packet, | 860 | * print the rtmp packet, use srs_human_trace/srs_human_verbose for packet, |
| 726 | * and use srs_human_raw for script data body. | 861 | * and use srs_human_raw for script data body. |
| 727 | * @return an error code for parse the timetstamp to dts and pts. | 862 | * @return an error code for parse the timetstamp to dts and pts. |
-
请 注册 或 登录 后发表评论