亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rtsp.c

?? rtsp協(xié)議的主要實現(xiàn)代碼
?? C
?? 第 1 頁 / 共 4 頁
字號:
/*
 * RTSP/SDP client
 * Copyright (c) 2002 Fabrice Bellard.
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
#include "avformat.h"

#include <sys/time.h>
#include <unistd.h> /* for select() prototype */
#include "network.h"

#include "rtp_internal.h"

//#define DEBUG
//#define DEBUG_RTP_TCP

enum RTSPClientState {
    RTSP_STATE_IDLE,
    RTSP_STATE_PLAYING,
    RTSP_STATE_PAUSED,
};

typedef struct RTSPState {
    URLContext *rtsp_hd; /* RTSP TCP connexion handle */
    int nb_rtsp_streams;
    struct RTSPStream **rtsp_streams;

    enum RTSPClientState state;
    int64_t seek_timestamp;

    /* XXX: currently we use unbuffered input */
    //    ByteIOContext rtsp_gb;
    int seq;        /* RTSP command sequence number */
    char session_id[512];
    enum RTSPProtocol protocol;
    char last_reply[2048]; /* XXX: allocate ? */
    RTPDemuxContext *cur_rtp;
} RTSPState;

typedef struct RTSPStream {
    URLContext *rtp_handle; /* RTP stream handle */
    RTPDemuxContext *rtp_ctx; /* RTP parse context */

    int stream_index; /* corresponding stream index, if any. -1 if none (MPEG2TS case) */
    int interleaved_min, interleaved_max;  /* interleave ids, if TCP transport */
    char control_url[1024]; /* url for this stream (from SDP) */

    int sdp_port; /* port (from SDP content - not used in RTSP) */
    struct in_addr sdp_ip; /* IP address  (from SDP content - not used in RTSP) */
    int sdp_ttl;  /* IP TTL (from SDP content - not used in RTSP) */
    int sdp_payload_type; /* payload type - only used in SDP */
    rtp_payload_data_t rtp_payload_data; /* rtp payload parsing infos from SDP */

    RTPDynamicProtocolHandler *dynamic_handler; ///< Only valid if it's a dynamic protocol. (This is the handler structure)
    void *dynamic_protocol_context; ///< Only valid if it's a dynamic protocol. (This is any private data associated with the dynamic protocol)
} RTSPStream;

static int rtsp_read_play(AVFormatContext *s);

/* XXX: currently, the only way to change the protocols consists in
   changing this variable */

int rtsp_default_protocols = (1 << RTSP_PROTOCOL_RTP_UDP);

FFRTSPCallback *ff_rtsp_callback = NULL;

static int rtsp_probe(AVProbeData *p)
{
    if (strstart(p->filename, "rtsp:", NULL))
        return AVPROBE_SCORE_MAX;
    return 0;
}

static int redir_isspace(int c)
{
    return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
}

static void skip_spaces(const char **pp)
{
    const char *p;
    p = *pp;
    while (redir_isspace(*p))
        p++;
    *pp = p;
}

static void get_word_sep(char *buf, int buf_size, const char *sep,
                         const char **pp)
{
    const char *p;
    char *q;

    p = *pp;
    if (*p == '/')
        p++;
    skip_spaces(&p);
    q = buf;
    while (!strchr(sep, *p) && *p != '\0') {
        if ((q - buf) < buf_size - 1)
            *q++ = *p;
        p++;
    }
    if (buf_size > 0)
        *q = '\0';
    *pp = p;
}

static void get_word(char *buf, int buf_size, const char **pp)
{
    const char *p;
    char *q;

    p = *pp;
    skip_spaces(&p);
    q = buf;
    while (!redir_isspace(*p) && *p != '\0') {
        if ((q - buf) < buf_size - 1)
            *q++ = *p;
        p++;
    }
    if (buf_size > 0)
        *q = '\0';
    *pp = p;
}

/* parse the rtpmap description: <codec_name>/<clock_rate>[/<other
   params>] */
static int sdp_parse_rtpmap(AVCodecContext *codec, RTSPStream *rtsp_st, int payload_type, const char *p)
{
    char buf[256];
    int i;
    AVCodec *c;
    const char *c_name;

    /* Loop into AVRtpDynamicPayloadTypes[] and AVRtpPayloadTypes[] and
       see if we can handle this kind of payload */
    get_word_sep(buf, sizeof(buf), "/", &p);
    if (payload_type >= RTP_PT_PRIVATE) {
        RTPDynamicProtocolHandler *handler= RTPFirstDynamicPayloadHandler;
        while(handler) {
            if (!strcmp(buf, handler->enc_name) && (codec->codec_type == handler->codec_type)) {
                codec->codec_id = handler->codec_id;
                rtsp_st->dynamic_handler= handler;
                if(handler->open) {
                    rtsp_st->dynamic_protocol_context= handler->open();
                }
                break;
            }
            handler= handler->next;
        }
    } else {
        /* We are in a standard case ( from http://www.iana.org/assignments/rtp-parameters) */
        /* search into AVRtpPayloadTypes[] */
        for (i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i)
            if (!strcmp(buf, AVRtpPayloadTypes[i].enc_name) && (codec->codec_type == AVRtpPayloadTypes[i].codec_type)){
                codec->codec_id = AVRtpPayloadTypes[i].codec_id;
                break;
            }
    }

    c = avcodec_find_decoder(codec->codec_id);
    if (c && c->name)
        c_name = c->name;
    else
        c_name = (char *)NULL;

    if (c_name) {
        get_word_sep(buf, sizeof(buf), "/", &p);
        i = atoi(buf);
        switch (codec->codec_type) {
            case CODEC_TYPE_AUDIO:
                av_log(codec, AV_LOG_DEBUG, " audio codec set to : %s\n", c_name);
                codec->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
                codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
                if (i > 0) {
                    codec->sample_rate = i;
                    get_word_sep(buf, sizeof(buf), "/", &p);
                    i = atoi(buf);
                    if (i > 0)
                        codec->channels = i;
                    // TODO: there is a bug here; if it is a mono stream, and less than 22000Hz, faad upconverts to stereo and twice the
                    //  frequency.  No problem, but the sample rate is being set here by the sdp line.  Upcoming patch forthcoming. (rdm)
                }
                av_log(codec, AV_LOG_DEBUG, " audio samplerate set to : %i\n", codec->sample_rate);
                av_log(codec, AV_LOG_DEBUG, " audio channels set to : %i\n", codec->channels);
                break;
            case CODEC_TYPE_VIDEO:
                av_log(codec, AV_LOG_DEBUG, " video codec set to : %s\n", c_name);
                break;
            default:
                break;
        }
        return 0;
    }

    return -1;
}

/* return the length and optionnaly the data */
static int hex_to_data(uint8_t *data, const char *p)
{
    int c, len, v;

    len = 0;
    v = 1;
    for(;;) {
        skip_spaces(&p);
        if (p == '\0')
            break;
        c = toupper((unsigned char)*p++);
        if (c >= '0' && c <= '9')
            c = c - '0';
        else if (c >= 'A' && c <= 'F')
            c = c - 'A' + 10;
        else
            break;
        v = (v << 4) | c;
        if (v & 0x100) {
            if (data)
                data[len] = v;
            len++;
            v = 1;
        }
    }
    return len;
}

static void sdp_parse_fmtp_config(AVCodecContext *codec, char *attr, char *value)
{
    switch (codec->codec_id) {
        case CODEC_ID_MPEG4:
        case CODEC_ID_AAC:
            if (!strcmp(attr, "config")) {
                /* decode the hexa encoded parameter */
                int len = hex_to_data(NULL, value);
                codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
                if (!codec->extradata)
                    return;
                codec->extradata_size = len;
                hex_to_data(codec->extradata, value);
            }
            break;
        default:
            break;
    }
    return;
}

typedef struct attrname_map
{
    const char *str;
    uint16_t type;
    uint32_t offset;
} attrname_map_t;

/* All known fmtp parmeters and the corresping RTPAttrTypeEnum */
#define ATTR_NAME_TYPE_INT 0
#define ATTR_NAME_TYPE_STR 1
static attrname_map_t attr_names[]=
{
    {"SizeLength",       ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, sizelength)},
    {"IndexLength",      ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, indexlength)},
    {"IndexDeltaLength", ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, indexdeltalength)},
    {"profile-level-id", ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, profile_level_id)},
    {"StreamType",       ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, streamtype)},
    {"mode",             ATTR_NAME_TYPE_STR, offsetof(rtp_payload_data_t, mode)},
    {NULL, -1, -1},
};

/** parse the attribute line from the fmtp a line of an sdp resonse.  This is broken out as a function
* because it is used in rtp_h264.c, which is forthcoming.
*/
int rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size)
{
    skip_spaces(p);
    if(**p)
    {
        get_word_sep(attr, attr_size, "=", p);
        if (**p == '=')
            (*p)++;
        get_word_sep(value, value_size, ";", p);
        if (**p == ';')
            (*p)++;
        return 1;
    }
    return 0;
}

/* parse a SDP line and save stream attributes */
static void sdp_parse_fmtp(AVStream *st, const char *p)
{
    char attr[256];
    char value[4096];
    int i;

    RTSPStream *rtsp_st = st->priv_data;
    AVCodecContext *codec = st->codec;
    rtp_payload_data_t *rtp_payload_data = &rtsp_st->rtp_payload_data;

    /* loop on each attribute */
    while(rtsp_next_attr_and_value(&p, attr, sizeof(attr), value, sizeof(value)))
    {
        /* grab the codec extra_data from the config parameter of the fmtp line */
        sdp_parse_fmtp_config(codec, attr, value);
        /* Looking for a known attribute */
        for (i = 0; attr_names[i].str; ++i) {
            if (!strcasecmp(attr, attr_names[i].str)) {
                if (attr_names[i].type == ATTR_NAME_TYPE_INT)
                    *(int *)((char *)rtp_payload_data + attr_names[i].offset) = atoi(value);
                else if (attr_names[i].type == ATTR_NAME_TYPE_STR)
                    *(char **)((char *)rtp_payload_data + attr_names[i].offset) = av_strdup(value);
            }
        }
    }
}

/** Parse a string \p in the form of Range:npt=xx-xx, and determine the start
 *  and end time.
 *  Used for seeking in the rtp stream.
 */
static void rtsp_parse_range_npt(const char *p, int64_t *start, int64_t *end)
{
    char buf[256];

    skip_spaces(&p);
    if (!stristart(p, "npt=", &p))
        return;

    *start = AV_NOPTS_VALUE;
    *end = AV_NOPTS_VALUE;

    get_word_sep(buf, sizeof(buf), "-", &p);
    *start = parse_date(buf, 1);
    if (*p == '-') {
        p++;
        get_word_sep(buf, sizeof(buf), "-", &p);
        *end = parse_date(buf, 1);
    }
//    av_log(NULL, AV_LOG_DEBUG, "Range Start: %lld\n", *start);
//    av_log(NULL, AV_LOG_DEBUG, "Range End: %lld\n", *end);
}

typedef struct SDPParseState {
    /* SDP only */
    struct in_addr default_ip;
    int default_ttl;
} SDPParseState;

static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
                           int letter, const char *buf)
{
    RTSPState *rt = s->priv_data;
    char buf1[64], st_type[64];
    const char *p;
    int codec_type, payload_type, i;
    AVStream *st;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧洲激情一区二区| 国产成人午夜高潮毛片| 欧美午夜精品免费| 樱桃视频在线观看一区| 欧美色中文字幕| 日韩电影在线免费观看| 日韩欧美视频在线| 国产精品一区在线| 国产精品美女久久久久aⅴ | 精品国产露脸精彩对白| 免费成人在线视频观看| 国产亚洲综合在线| 色综合视频在线观看| 亚洲电影欧美电影有声小说| 欧美大黄免费观看| 岛国精品在线观看| 亚洲成人午夜电影| 久久久午夜电影| 色婷婷久久久亚洲一区二区三区| 亚洲国产成人tv| 精品国产制服丝袜高跟| 91免费视频观看| 蜜桃免费网站一区二区三区| 欧美国产视频在线| 欧美日韩国产经典色站一区二区三区| 久久国产精品免费| 亚洲视频图片小说| 日韩一区二区三区在线观看| 成人精品免费视频| 天堂在线亚洲视频| 中文字幕一区不卡| 日韩午夜在线播放| 色综合久久中文综合久久97| 蜜臀av一区二区三区| 1000部国产精品成人观看| 日韩欧美一区在线观看| 成人av片在线观看| 久久精品久久精品| 亚洲午夜在线视频| 国产精品高潮久久久久无| 欧美高清dvd| 91玉足脚交白嫩脚丫在线播放| 奇米亚洲午夜久久精品| 亚洲人成网站色在线观看| 精品欧美一区二区久久| 91福利视频久久久久| 成人做爰69片免费看网站| 男女男精品视频网| 一区二区三区成人| 亚洲国产精品t66y| 日韩欧美高清dvd碟片| 欧美在线综合视频| 99视频精品全部免费在线| 激情五月播播久久久精品| 夜夜嗨av一区二区三区中文字幕 | av中文字幕一区| 久久精品免费看| 视频一区二区欧美| 亚洲一区二区三区激情| 亚洲男女一区二区三区| 国产偷国产偷亚洲高清人白洁| 日韩欧美国产一二三区| 欧美三级韩国三级日本三斤| 99re成人在线| 91在线精品一区二区| 福利电影一区二区三区| 精品一区二区av| 蜜桃视频在线观看一区| 天堂va蜜桃一区二区三区 | 久久久精品日韩欧美| 日韩欧美在线123| 欧美一区二区三区视频在线观看| 在线免费精品视频| 国产精品天干天干在观线| 精品国产乱码久久久久久老虎| 欧美日韩在线观看一区二区| 精品婷婷伊人一区三区三| 日本精品裸体写真集在线观看| 91麻豆免费在线观看| 91丨porny丨国产| 色爱区综合激月婷婷| 一本色道亚洲精品aⅴ| 91极品视觉盛宴| 欧美午夜一区二区| 欧美乱妇15p| 欧美精品在线观看播放| 日韩精品最新网址| 亚洲精品一线二线三线| 久久人人超碰精品| 中文字幕在线免费不卡| 亚洲日本va午夜在线影院| 亚洲激情网站免费观看| 亚洲成av人片在线观看| 奇米亚洲午夜久久精品| 国产激情视频一区二区在线观看| 91精品国产乱码久久蜜臀| 337p日本欧洲亚洲大胆色噜噜| 久久久久久久久久久久久久久99 | 蜜臀va亚洲va欧美va天堂| 久久精品久久99精品久久| 国产激情91久久精品导航| 成人v精品蜜桃久久一区| 欧洲中文字幕精品| 欧美成人乱码一区二区三区| 国产免费久久精品| 一区二区三区四区不卡视频| 日韩电影免费在线看| 国产精品一区在线| 日本一区二区电影| 亚洲精品日韩一| 青青草原综合久久大伊人精品优势 | 欧美美女直播网站| 精品国产乱码久久久久久牛牛 | 亚洲三级视频在线观看| 丝袜a∨在线一区二区三区不卡| 黄网站免费久久| 在线视频你懂得一区二区三区| 91精品啪在线观看国产60岁| 国产免费观看久久| 日韩成人一级片| 成人av网在线| 日韩一区二区三区四区| 综合欧美一区二区三区| 欧美日韩国产一区二区三区地区| 日韩小视频在线观看专区| 国产精品不卡一区| 精品制服美女丁香| 在线欧美日韩国产| 欧美激情综合在线| 七七婷婷婷婷精品国产| 91在线观看视频| 久久久综合网站| 丝袜美腿亚洲综合| 色网综合在线观看| 欧美激情综合网| 美女精品一区二区| 欧美中文字幕一二三区视频| 久久久蜜桃精品| 蜜臀久久99精品久久久久久9 | 2017欧美狠狠色| 图片区小说区国产精品视频| 丁香六月综合激情| wwwwxxxxx欧美| 日av在线不卡| 欧美日韩一区中文字幕| 亚洲欧洲av色图| 国产suv一区二区三区88区| 日韩欧美中文一区二区| 亚洲成a人片综合在线| 91九色02白丝porn| 日韩美女视频一区二区| 懂色av中文一区二区三区| 精品久久久三级丝袜| 日韩电影免费在线观看网站| 欧美午夜寂寞影院| 亚洲自拍另类综合| 日本韩国欧美一区二区三区| 老汉av免费一区二区三区| 欧美日韩午夜在线| 亚洲成人精品在线观看| 欧美性感一区二区三区| 一区二区三区欧美日| 色婷婷国产精品| 伊人性伊人情综合网| 99re66热这里只有精品3直播| 国产精品视频看| 成人午夜私人影院| 国产精品蜜臀在线观看| 白白色 亚洲乱淫| 亚洲国产精品99久久久久久久久| 国产一区二区三区香蕉| 国产三级久久久| 成人午夜在线播放| 亚洲码国产岛国毛片在线| 91久久国产最好的精华液| 亚洲一区二区不卡免费| 欧美日韩高清影院| 蜜桃精品视频在线观看| www精品美女久久久tv| 在线成人av网站| 奇米影视一区二区三区| 欧美精品一区二区三区四区| 国产精品一区二区91| 中文字幕色av一区二区三区| 91天堂素人约啪| 午夜电影一区二区三区| xvideos.蜜桃一区二区| 成人午夜av电影| 亚洲午夜激情网页| 欧美一区二区三区色| 国产精品一级片在线观看| 国产精品不卡在线| 欧美精品丝袜久久久中文字幕| 美女任你摸久久| 国产精品天美传媒沈樵| 欧美日本一区二区三区| 激情欧美一区二区三区在线观看| 中文字幕永久在线不卡| 欧美老肥妇做.爰bbww视频| 韩日精品视频一区|