comparison rtsp.c @ 6357:b7ee8424b7e6 libavformat

get ride of MAX_STREAMS limit in RTSP
author aurel
date Mon, 09 Aug 2010 23:00:13 +0000
parents aea92c85d611
children f8c3cb8c503e
comparison
equal deleted inserted replaced
6356:2048bf728893 6357:b7ee8424b7e6
1609 1609
1610 #if CONFIG_RTSP_DEMUXER 1610 #if CONFIG_RTSP_DEMUXER
1611 static int rtsp_read_header(AVFormatContext *s, 1611 static int rtsp_read_header(AVFormatContext *s,
1612 AVFormatParameters *ap) 1612 AVFormatParameters *ap)
1613 { 1613 {
1614 RTSPState *rt = s->priv_data;
1614 int ret; 1615 int ret;
1615 1616
1616 ret = ff_rtsp_connect(s); 1617 ret = ff_rtsp_connect(s);
1617 if (ret) 1618 if (ret)
1618 return ret; 1619 return ret;
1620
1621 rt->real_setup_cache = av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));
1622 if (!rt->real_setup_cache)
1623 return AVERROR(ENOMEM);
1624 rt->real_setup = rt->real_setup_cache + s->nb_streams * sizeof(*rt->real_setup);
1619 1625
1620 if (ap->initial_pause) { 1626 if (ap->initial_pause) {
1621 /* do not start immediately */ 1627 /* do not start immediately */
1622 } else { 1628 } else {
1623 if (rtsp_read_play(s) < 0) { 1629 if (rtsp_read_play(s) < 0) {
1833 RTSPMessageHeader reply1, *reply = &reply1; 1839 RTSPMessageHeader reply1, *reply = &reply1;
1834 char cmd[1024]; 1840 char cmd[1024];
1835 1841
1836 if (rt->server_type == RTSP_SERVER_REAL) { 1842 if (rt->server_type == RTSP_SERVER_REAL) {
1837 int i; 1843 int i;
1838 enum AVDiscard cache[MAX_STREAMS];
1839 1844
1840 for (i = 0; i < s->nb_streams; i++) 1845 for (i = 0; i < s->nb_streams; i++)
1841 cache[i] = s->streams[i]->discard; 1846 rt->real_setup[i] = s->streams[i]->discard;
1842 1847
1843 if (!rt->need_subscription) { 1848 if (!rt->need_subscription) {
1844 if (memcmp (cache, rt->real_setup_cache, 1849 if (memcmp (rt->real_setup, rt->real_setup_cache,
1845 sizeof(enum AVDiscard) * s->nb_streams)) { 1850 sizeof(enum AVDiscard) * s->nb_streams)) {
1846 snprintf(cmd, sizeof(cmd), 1851 snprintf(cmd, sizeof(cmd),
1847 "Unsubscribe: %s\r\n", 1852 "Unsubscribe: %s\r\n",
1848 rt->last_subscription); 1853 rt->last_subscription);
1849 ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, 1854 ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri,
1855 } 1860 }
1856 1861
1857 if (rt->need_subscription) { 1862 if (rt->need_subscription) {
1858 int r, rule_nr, first = 1; 1863 int r, rule_nr, first = 1;
1859 1864
1860 memcpy(rt->real_setup_cache, cache, 1865 memcpy(rt->real_setup_cache, rt->real_setup,
1861 sizeof(enum AVDiscard) * s->nb_streams); 1866 sizeof(enum AVDiscard) * s->nb_streams);
1862 rt->last_subscription[0] = 0; 1867 rt->last_subscription[0] = 0;
1863 1868
1864 snprintf(cmd, sizeof(cmd), 1869 snprintf(cmd, sizeof(cmd),
1865 "Subscribe: "); 1870 "Subscribe: ");
1967 ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL); 1972 ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
1968 1973
1969 ff_rtsp_close_streams(s); 1974 ff_rtsp_close_streams(s);
1970 ff_rtsp_close_connections(s); 1975 ff_rtsp_close_connections(s);
1971 ff_network_close(); 1976 ff_network_close();
1977 rt->real_setup = NULL;
1978 av_freep(&rt->real_setup_cache);
1972 return 0; 1979 return 0;
1973 } 1980 }
1974 1981
1975 AVInputFormat rtsp_demuxer = { 1982 AVInputFormat rtsp_demuxer = {
1976 "rtsp", 1983 "rtsp",