| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Multiple format streaming server | 2 * Multiple format streaming server |
| 3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | 3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 "SEND_DATA_TRAILER", | 85 "SEND_DATA_TRAILER", |
| 86 "RECEIVE_DATA", | 86 "RECEIVE_DATA", |
| 87 "WAIT_FEED", | 87 "WAIT_FEED", |
| 88 "READY", | 88 "READY", |
| 89 | 89 |
| 90 "RTSP_WAIT_REQUEST", | 90 "RTSP_WAIT_REQUEST", |
| 91 "RTSP_SEND_REPLY", | 91 "RTSP_SEND_REPLY", |
| 92 "RTSP_SEND_PACKET", | 92 "RTSP_SEND_PACKET", |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 #if !FF_API_MAX_STREAMS |
| 96 #define MAX_STREAMS 20 |
| 97 #endif |
| 98 |
| 95 #define IOBUFFER_INIT_SIZE 8192 | 99 #define IOBUFFER_INIT_SIZE 8192 |
| 96 | 100 |
| 97 /* timeouts are in ms */ | 101 /* timeouts are in ms */ |
| 98 #define HTTP_REQUEST_TIMEOUT (15 * 1000) | 102 #define HTTP_REQUEST_TIMEOUT (15 * 1000) |
| 99 #define RTSP_REQUEST_TIMEOUT (3600 * 24 * 1000) | 103 #define RTSP_REQUEST_TIMEOUT (3600 * 24 * 1000) |
| 100 | 104 |
| 101 #define SYNC_TIMEOUT (10 * 1000) | 105 #define SYNC_TIMEOUT (10 * 1000) |
| 102 | 106 |
| 103 typedef struct RTSPActionServerSetup { | 107 typedef struct RTSPActionServerSetup { |
| 104 uint32_t ipaddr; | 108 uint32_t ipaddr; |
| (...skipping 2818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2923 c->buffer_ptr = c->pb_buffer; | 2927 c->buffer_ptr = c->pb_buffer; |
| 2924 c->buffer_end = c->pb_buffer + len; | 2928 c->buffer_end = c->pb_buffer + len; |
| 2925 c->state = RTSPSTATE_SEND_REPLY; | 2929 c->state = RTSPSTATE_SEND_REPLY; |
| 2926 return 0; | 2930 return 0; |
| 2927 } | 2931 } |
| 2928 | 2932 |
| 2929 static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, | 2933 static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, |
| 2930 struct in_addr my_ip) | 2934 struct in_addr my_ip) |
| 2931 { | 2935 { |
| 2932 AVFormatContext *avc; | 2936 AVFormatContext *avc; |
| 2933 AVStream avs[MAX_STREAMS]; | 2937 AVStream *avs = NULL; |
| 2934 int i; | 2938 int i; |
| 2935 | 2939 |
| 2936 avc = avformat_alloc_context(); | 2940 avc = avformat_alloc_context(); |
| 2937 if (avc == NULL) { | 2941 if (avc == NULL) { |
| 2938 return -1; | 2942 return -1; |
| 2939 } | 2943 } |
| 2940 av_metadata_set2(&avc->metadata, "title", | 2944 av_metadata_set2(&avc->metadata, "title", |
| 2941 stream->title[0] ? stream->title : "No Title", 0); | 2945 stream->title[0] ? stream->title : "No Title", 0); |
| 2942 avc->nb_streams = stream->nb_streams; | 2946 avc->nb_streams = stream->nb_streams; |
| 2943 if (stream->is_multicast) { | 2947 if (stream->is_multicast) { |
| 2944 snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d", | 2948 snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d", |
| 2945 inet_ntoa(stream->multicast_ip), | 2949 inet_ntoa(stream->multicast_ip), |
| 2946 stream->multicast_port, stream->multicast_ttl); | 2950 stream->multicast_port, stream->multicast_ttl); |
| 2947 } else { | 2951 } else { |
| 2948 snprintf(avc->filename, 1024, "rtp://0.0.0.0"); | 2952 snprintf(avc->filename, 1024, "rtp://0.0.0.0"); |
| 2949 } | 2953 } |
| 2950 | 2954 |
| 2955 #if !FF_API_MAX_STREAMS |
| 2956 if (avc->nb_streams >= INT_MAX/sizeof(*avc->streams) || |
| 2957 !(avc->streams = av_malloc(avc->nb_streams * sizeof(*avc->streams)))) |
| 2958 goto sdp_done; |
| 2959 #endif |
| 2960 if (avc->nb_streams >= INT_MAX/sizeof(*avs) || |
| 2961 !(avs = av_malloc(avc->nb_streams * sizeof(*avs)))) |
| 2962 goto sdp_done; |
| 2963 |
| 2951 for(i = 0; i < stream->nb_streams; i++) { | 2964 for(i = 0; i < stream->nb_streams; i++) { |
| 2952 avc->streams[i] = &avs[i]; | 2965 avc->streams[i] = &avs[i]; |
| 2953 avc->streams[i]->codec = stream->streams[i]->codec; | 2966 avc->streams[i]->codec = stream->streams[i]->codec; |
| 2954 } | 2967 } |
| 2955 *pbuffer = av_mallocz(2048); | 2968 *pbuffer = av_mallocz(2048); |
| 2956 avf_sdp_create(&avc, 1, *pbuffer, 2048); | 2969 avf_sdp_create(&avc, 1, *pbuffer, 2048); |
| 2970 |
| 2971 sdp_done: |
| 2972 #if !FF_API_MAX_STREAMS |
| 2973 av_free(avc->streams); |
| 2974 #endif |
| 2957 av_metadata_free(&avc->metadata); | 2975 av_metadata_free(&avc->metadata); |
| 2958 av_free(avc); | 2976 av_free(avc); |
| 2977 av_free(avs); |
| 2959 | 2978 |
| 2960 return strlen(*pbuffer); | 2979 return strlen(*pbuffer); |
| 2961 } | 2980 } |
| 2962 | 2981 |
| 2963 static void rtsp_cmd_options(HTTPContext *c, const char *url) | 2982 static void rtsp_cmd_options(HTTPContext *c, const char *url) |
| 2964 { | 2983 { |
| 2965 // rtsp_reply_header(c, RTSP_STATUS_OK); | 2984 // rtsp_reply_header(c, RTSP_STATUS_OK); |
| 2966 url_fprintf(c->pb, "RTSP/1.0 %d %s\r\n", RTSP_STATUS_OK, "OK"); | 2985 url_fprintf(c->pb, "RTSP/1.0 %d %s\r\n", RTSP_STATUS_OK, "OK"); |
| 2967 url_fprintf(c->pb, "CSeq: %d\r\n", c->seq); | 2986 url_fprintf(c->pb, "CSeq: %d\r\n", c->seq); |
| 2968 url_fprintf(c->pb, "Public: %s\r\n", "OPTIONS, DESCRIBE, SETUP, TEARDOWN, PL
AY, PAUSE"); | 2987 url_fprintf(c->pb, "Public: %s\r\n", "OPTIONS, DESCRIBE, SETUP, TEARDOWN, PL
AY, PAUSE"); |
| (...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4760 if (ffserver_daemon) | 4779 if (ffserver_daemon) |
| 4761 chdir("/"); | 4780 chdir("/"); |
| 4762 | 4781 |
| 4763 if (http_server() < 0) { | 4782 if (http_server() < 0) { |
| 4764 http_log("Could not start server\n"); | 4783 http_log("Could not start server\n"); |
| 4765 exit(1); | 4784 exit(1); |
| 4766 } | 4785 } |
| 4767 | 4786 |
| 4768 return 0; | 4787 return 0; |
| 4769 } | 4788 } |
| OLD | NEW |