annotate libmpdemux/demux_nemesi.c @ 25009:8af79723e63e

Revert stray commit r25027
author lu_zero
date Tue, 13 Nov 2007 22:57:22 +0000
parents cc8cb1bbd38e
children 9a4d15a28d12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
1 /*
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
2 * Copyright (C) 2007 Alessandro Molina <amol.wrk@gmail.com>
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
3 *
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
7 * (at your option) any later version.
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
8 *
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
12 * GNU General Public License for more details.
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
13 *
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
15 * along with MPlayer; if not, write to the Free Software Foundation,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
17 */
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
18
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
19 #include "demux_nemesi.h"
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
20 #include "stheader.h"
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
21 #define HAVE_STRUCT_SOCKADDR_STORAGE
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
22 #include "nemesi/rtsp.h"
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
23 #include "nemesi/rtp.h"
24856
4365a0d7a4b8 Fix fps guessing
lu_zero
parents: 24855
diff changeset
24 #include <sched.h>
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
25
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
26 int rtsp_transport_tcp = 0;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
27 int rtsp_transport_sctp = 0;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
28 // extern int rtsp_port;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
29
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
30 typedef enum { NEMESI_SESSION_VIDEO,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
31 NEMESI_SESSION_AUDIO } Nemesi_SessionType;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
32
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
33 typedef struct {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
34 rtsp_ctrl * rtsp;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
35 rtp_session * session[2];
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
36 rtp_frame first_pkt[2];
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
37 double time[2];
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
38 double seek;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
39 } Nemesi_DemuxerStreamData;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
40
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
41
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
42 #define STYPE_TO_DS(demuxer, stype) \
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
43 ((stype) == NEMESI_SESSION_VIDEO ? (demuxer)->video : (demuxer)->audio)
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
44
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
45 #define DS_TO_STYPE(demuxer, ds) \
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
46 ((ds) == (demuxer)->video ? NEMESI_SESSION_VIDEO : NEMESI_SESSION_AUDIO)
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
47
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
48 #define INVERT_STYPE(stype) ((stype + 1) % 2)
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
49
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
50
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
51 static rtp_ssrc *wait_for_packets(Nemesi_DemuxerStreamData * ndsd, Nemesi_SessionType stype)
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
52 {
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
53 rtp_ssrc *ssrc = NULL;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
54
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
55 /* Wait for prebuffering (prebuffering must be enabled in nemesi) */
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
56 int terminated = rtp_fill_buffers(rtsp_get_rtp_th(ndsd->rtsp));
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
57
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
58 /* Wait for the ssrc to be registered, if prebuffering is on in nemesi
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
59 this will just get immediatly the correct ssrc */
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
60 if (!terminated) {
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
61 while ( !(ssrc = rtp_session_get_ssrc(ndsd->session[stype], ndsd->rtsp)) )
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
62 sched_yield();
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
63 }
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
64
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
65 return ssrc;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
66 }
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
67
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
68 static void link_session_and_fetch_conf(Nemesi_DemuxerStreamData * ndsd,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
69 Nemesi_SessionType stype,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
70 rtp_session * sess,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
71 rtp_buff * buff, unsigned int * fps)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
72 {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
73 extern float force_fps;
24855
2c790baff42c Update to use newer libnemesi, should fix desync, fps guessing may fail now
lu_zero
parents: 24625
diff changeset
74 rtp_ssrc *ssrc = NULL;
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
75 rtp_frame * fr = &ndsd->first_pkt[stype];
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
76 rtp_buff trash_buff;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
77
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
78 ndsd->session[stype] = sess;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
79
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
80 ssrc = wait_for_packets(ndsd, stype);
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
81
25009
8af79723e63e Revert stray commit r25027
lu_zero
parents: 25006
diff changeset
82 if ( (ssrc) && (fps != NULL) ) {
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
83 if (buff == NULL)
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
84 buff = &trash_buff;
24856
4365a0d7a4b8 Fix fps guessing
lu_zero
parents: 24855
diff changeset
85
4365a0d7a4b8 Fix fps guessing
lu_zero
parents: 24855
diff changeset
86 rtp_fill_buffer(ssrc, fr, buff); //Prefetch the first packet
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
87
24998
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
88 /* Packet prefecthing must be done anyway or we won't be
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
89 able to get the metadata, but fps calculation happens
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
90 only if the user didn't specify the FPS */
25009
8af79723e63e Revert stray commit r25027
lu_zero
parents: 25006
diff changeset
91 if (!force_fps) {
24998
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
92 while ( *fps <= 0 ) {
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
93 //Wait more pkts to calculate FPS and try again
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
94 sched_yield();
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
95 *fps = rtp_get_fps(ssrc);
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
96 }
c6aaf2165751 fix forcefps (from amol)
lu_zero
parents: 24997
diff changeset
97 }
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
98 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
99 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
100
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
101 demuxer_t* demux_open_rtp(demuxer_t* demuxer)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
102 {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
103 nms_rtsp_hints hints;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
104 char * url = demuxer->stream->streaming_ctrl->url->url;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
105 rtsp_ctrl * ctl;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
106 RTSP_Error reply;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
107 rtsp_medium * media;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
108 Nemesi_DemuxerStreamData * ndsd = calloc(1, sizeof(Nemesi_DemuxerStreamData));
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
109
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
110 memset(&hints,0,sizeof(hints));
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
111 // if (rtsp_port) hints.first_rtp_port = rtsp_port;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
112 if (rtsp_transport_tcp) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
113 hints.pref_rtsp_proto = TCP;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
114 hints.pref_rtp_proto = TCP;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
115 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
116 if (rtsp_transport_sctp) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
117 hints.pref_rtsp_proto = SCTP;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
118 hints.pref_rtp_proto = SCTP;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
119 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
120
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
121 mp_msg(MSGT_DEMUX, MSGL_INFO, "Initializing libNemesi\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
122 if ((ctl = rtsp_init(&hints)) == NULL) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
123 free(ndsd);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
124 return STREAM_ERROR;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
125 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
126
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
127 ndsd->rtsp = ctl;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
128 demuxer->priv = ndsd;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
129 //nms_verbosity_set(1);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
130
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
131 mp_msg(MSGT_DEMUX, MSGL_INFO, "Opening: %s\n", url);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
132 if (rtsp_open(ctl, url)) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
133 mp_msg(MSGT_DEMUX, MSGL_ERR, "rtsp_open failed.\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
134 return demuxer;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
135 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
136
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
137 reply = rtsp_wait(ctl);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
138 if (reply.got_error) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
139 mp_msg(MSGT_DEMUX, MSGL_ERR,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
140 "OPEN Error from the server: %s\n",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
141 reply.message.reply_str);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
142 return demuxer;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
143 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
144
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
145 rtsp_play(ctl, 0, 0);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
146 reply = rtsp_wait(ctl);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
147 if (reply.got_error) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
148 mp_msg(MSGT_DEMUX, MSGL_ERR,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
149 "PLAY Error from the server: %s\n",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
150 reply.message.reply_str);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
151 return demuxer;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
152 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
153
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
154 media = ctl->rtsp_queue->media_queue;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
155 for (; media; media=media->next) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
156 sdp_medium_info * info = media->medium_info;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
157 rtp_session * sess = media->rtp_sess;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
158
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
159 int media_format = atoi(info->fmts);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
160 rtp_pt * ptinfo = rtp_get_pt_info(sess, media_format);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
161 char const * format_name = ptinfo ? ptinfo->name : NULL;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
162
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
163 if (sess->parsers[media_format] == NULL) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
164 mp_msg(MSGT_DEMUX, MSGL_ERR,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
165 "libNemesi unsupported media format: %s\n",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
166 format_name ? format_name : info->fmts);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
167 continue;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
168 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
169 else {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
170 mp_msg(MSGT_DEMUX, MSGL_INFO,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
171 "libNemesi supported media: %s\n",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
172 format_name);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
173 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
174
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
175 if (ptinfo->type == AU) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
176 if (ndsd->session[NEMESI_SESSION_AUDIO] == NULL) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
177 sh_audio_t* sh_audio = new_sh_audio(demuxer,0);
25009
8af79723e63e Revert stray commit r25027
lu_zero
parents: 25006
diff changeset
178 WAVEFORMATEX* wf = calloc(1,sizeof(WAVEFORMATEX));
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
179 demux_stream_t* d_audio = demuxer->audio;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
180
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
181 mp_msg(MSGT_DEMUX, MSGL_INFO, "Detected as AUDIO stream...\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
182
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
183 link_session_and_fetch_conf(ndsd, NEMESI_SESSION_AUDIO,
25009
8af79723e63e Revert stray commit r25027
lu_zero
parents: 25006
diff changeset
184 sess, NULL, NULL);
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
185
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
186 sh_audio->wf = wf;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
187 d_audio->sh = sh_audio;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
188 sh_audio->ds = d_audio;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
189 wf->nSamplesPerSec = 0;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
190
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
191 //List of known audio formats
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
192 if (!strcmp(format_name, "MPA"))
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
193 wf->wFormatTag =
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
194 sh_audio->format = 0x55;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
195 else if (!strcmp(format_name, "vorbis"))
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
196 wf->wFormatTag =
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
197 sh_audio->format = mmioFOURCC('v','r','b','s');
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
198 else
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
199 mp_msg(MSGT_DEMUX, MSGL_WARN,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
200 "Unknown MPlayer format code for MIME"
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
201 " type \"audio/%s\"\n", format_name);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
202 } else {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
203 mp_msg(MSGT_DEMUX, MSGL_ERR,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
204 "There is already an audio session registered,"
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
205 " ignoring...\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
206 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
207 } else if (ptinfo->type == VI) {
25009
8af79723e63e Revert stray commit r25027
lu_zero
parents: 25006
diff changeset
208 if (ndsd->session[NEMESI_SESSION_AUDIO] == NULL) {
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
209 sh_video_t* sh_video;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
210 BITMAPINFOHEADER* bih;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
211 demux_stream_t* d_video;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
212 int fps = 0;
25009
8af79723e63e Revert stray commit r25027
lu_zero
parents: 25006
diff changeset
213 rtp_buff buff;
8af79723e63e Revert stray commit r25027
lu_zero
parents: 25006
diff changeset
214 memset(&buff, 0, sizeof(rtp_buff));
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
215
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
216 mp_msg(MSGT_DEMUX, MSGL_INFO, "Detected as VIDEO stream...\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
217
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
218 link_session_and_fetch_conf(ndsd, NEMESI_SESSION_VIDEO,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
219 sess, &buff, &fps);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
220
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
221 if (buff.len) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
222 bih = calloc(1,sizeof(BITMAPINFOHEADER)+buff.len);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
223 bih->biSize = sizeof(BITMAPINFOHEADER)+buff.len;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
224 memcpy(bih+1, buff.data, buff.len);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
225 } else {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
226 bih = calloc(1,sizeof(BITMAPINFOHEADER));
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
227 bih->biSize = sizeof(BITMAPINFOHEADER);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
228 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
229
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
230 sh_video = new_sh_video(demuxer,0);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
231 sh_video->bih = bih;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
232 d_video = demuxer->video;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
233 d_video->sh = sh_video;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
234 sh_video->ds = d_video;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
235
24856
4365a0d7a4b8 Fix fps guessing
lu_zero
parents: 24855
diff changeset
236 if (fps) {
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
237 sh_video->fps = fps;
24856
4365a0d7a4b8 Fix fps guessing
lu_zero
parents: 24855
diff changeset
238 sh_video->frametime = 1.0/fps;
4365a0d7a4b8 Fix fps guessing
lu_zero
parents: 24855
diff changeset
239 }
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
240
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
241 //List of known video formats
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
242 if (!strcmp(format_name, "MPV")) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
243 bih->biCompression =
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
244 sh_video->format = mmioFOURCC('M','P','E','G');
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
245 } else if (!strcmp(format_name, "H264")) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
246 bih->biCompression =
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
247 sh_video->format = mmioFOURCC('H','2','6','4');
24625
17a83ea47ee1 h263 exposed
lu_zero
parents: 24564
diff changeset
248 } else if (!strcmp(format_name, "H263-1998")) {
17a83ea47ee1 h263 exposed
lu_zero
parents: 24564
diff changeset
249 bih->biCompression =
17a83ea47ee1 h263 exposed
lu_zero
parents: 24564
diff changeset
250 sh_video->format = mmioFOURCC('H','2','6','3');
24999
903477cad47d Add support for mpeg4video-es (from dario)
lu_zero
parents: 24998
diff changeset
251 } else if (!strcmp(format_name, "MP4V-ES")) {
903477cad47d Add support for mpeg4video-es (from dario)
lu_zero
parents: 24998
diff changeset
252 bih->biCompression =
903477cad47d Add support for mpeg4video-es (from dario)
lu_zero
parents: 24998
diff changeset
253 sh_video->format = mmioFOURCC('M','P','4','V');
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
254 } else {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
255 mp_msg(MSGT_DEMUX, MSGL_WARN,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
256 "Unknown MPlayer format code for MIME"
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
257 " type \"video/%s\"\n", format_name);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
258 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
259 } else {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
260 mp_msg(MSGT_DEMUX, MSGL_ERR,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
261 "There is already a video session registered,"
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
262 " ignoring...\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
263 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
264 } else {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
265 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported media type\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
266 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
267 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
268
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
269 demuxer->stream->eof = 0;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
270
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
271 return demuxer;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
272 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
273
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
274 static int get_data_for_session(Nemesi_DemuxerStreamData * ndsd,
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
275 Nemesi_SessionType stype, rtp_ssrc * ssrc,
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
276 rtp_frame * fr)
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
277 {
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
278 if (ndsd->first_pkt[stype].len != 0) {
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
279 fr->data = ndsd->first_pkt[stype].data;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
280 fr->time_sec = ndsd->first_pkt[stype].time_sec;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
281 fr->len = ndsd->first_pkt[stype].len;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
282 ndsd->first_pkt[stype].len = 0;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
283 return RTP_FILL_OK;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
284 } else {
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
285 rtp_buff buff;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
286 return rtp_fill_buffer(ssrc, fr, &buff);
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
287 }
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
288 }
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
289
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
290 static void stream_add_packet(Nemesi_DemuxerStreamData * ndsd,
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
291 Nemesi_SessionType stype,
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
292 demux_stream_t* ds, rtp_frame * fr)
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
293 {
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
294 demux_packet_t* dp = new_demux_packet(fr->len);
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
295 memcpy(dp->buffer, fr->data, fr->len);
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
296
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
297 fr->time_sec += ndsd->seek;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
298 ndsd->time[stype] = dp->pts = fr->time_sec;
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
299
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
300 ds_add_packet(ds, dp);
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
301 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
302
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
303 int demux_rtp_fill_buffer(demuxer_t* demuxer, demux_stream_t* ds)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
304 {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
305 Nemesi_DemuxerStreamData * ndsd = demuxer->priv;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
306 Nemesi_SessionType stype;
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
307 rtp_ssrc * ssrc;
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
308 rtp_frame fr;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
309
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
310 if ( (!ndsd->rtsp->rtsp_queue) || (demuxer->stream->eof) ) {
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
311 mp_msg(MSGT_DEMUX, MSGL_INFO, "End of Stream...\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
312 demuxer->stream->eof = 1;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
313 return 0;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
314 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
315
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
316 stype = DS_TO_STYPE(demuxer, ds);
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
317 if ( (ssrc = wait_for_packets(ndsd, stype)) == NULL ) {
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
318 mp_msg(MSGT_DEMUX, MSGL_INFO, "Bye...\n");
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
319 demuxer->stream->eof = 1;
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
320 return 0;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
321 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
322
24997
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
323 if(!get_data_for_session(ndsd, stype, ssrc, &fr))
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
324 stream_add_packet(ndsd, stype, ds, &fr);
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
325 else {
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
326 stype = INVERT_STYPE(stype);
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
327 ds = STYPE_TO_DS(demuxer, stype);
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
328 ssrc = wait_for_packets(ndsd, stype);
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
329
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
330 if(!get_data_for_session(ndsd, stype, ssrc, &fr))
e429129fa02b Refactor demux_nemesi (from amol)
lu_zero
parents: 24856
diff changeset
331 stream_add_packet(ndsd, stype, ds, &fr);
24564
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
332 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
333
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
334 return 1;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
335 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
336
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
337
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
338 void demux_close_rtp(demuxer_t* demuxer)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
339 {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
340 Nemesi_DemuxerStreamData * ndsd = demuxer->priv;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
341 rtsp_ctrl * ctl = ndsd->rtsp;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
342 RTSP_Error err;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
343
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
344 mp_msg(MSGT_DEMUX, MSGL_INFO, "Closing libNemesi RTSP Stream...\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
345
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
346 if (ndsd == NULL)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
347 return;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
348
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
349 free(ndsd);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
350
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
351 if (rtsp_close(ctl)) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
352 err = rtsp_wait(ctl);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
353 if (err.got_error)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
354 mp_msg(MSGT_DEMUX, MSGL_ERR,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
355 "Error Closing Stream: %s\n",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
356 err.message.reply_str);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
357 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
358
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
359 rtsp_uninit(ctl);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
360 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
361
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
362 static void demux_seek_rtp(demuxer_t *demuxer, float rel_seek_secs,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
363 float audio_delay, int flags)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
364 {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
365 Nemesi_DemuxerStreamData * ndsd = demuxer->priv;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
366 rtsp_ctrl * ctl = ndsd->rtsp;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
367 sdp_attr * r_attr = NULL;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
368 sdp_range r = {0, 0};
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
369 double time = ndsd->time[NEMESI_SESSION_VIDEO] ?
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
370 ndsd->time[NEMESI_SESSION_VIDEO] :
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
371 ndsd->time[NEMESI_SESSION_AUDIO];
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
372
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
373 if (!ctl->rtsp_queue)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
374 return;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
375
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
376 r_attr = sdp_get_attr(ctl->rtsp_queue->info->attr_list, "range");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
377 if (r_attr)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
378 r = sdp_parse_range(r_attr->value);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
379
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
380 //flags & 1 -> absolute seek
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
381 //flags & 2 -> percent seek
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
382 if (flags == 0) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
383 time += rel_seek_secs;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
384 if (time < r.begin)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
385 time = r.begin;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
386 else if (time > r.end)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
387 time = r.end;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
388 ndsd->seek = time;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
389
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
390 mp_msg(MSGT_DEMUX,MSGL_WARN,"libNemesi SEEK %f on %f - %f)\n",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
391 time, r.begin, r.end);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
392
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
393 if (!rtsp_seek(ctl, time, 0)) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
394 RTSP_Error err = rtsp_wait(ctl);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
395 if (err.got_error) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
396 mp_msg(MSGT_DEMUX, MSGL_ERR,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
397 "Error Performing Seek: %s\n",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
398 err.message.reply_str);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
399 demuxer->stream->eof = 1;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
400 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
401 else
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
402 mp_msg(MSGT_DEMUX, MSGL_INFO, "Seek, performed\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
403 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
404 else {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
405 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unable to pause stream to perform seek\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
406 demuxer->stream->eof = 1;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
407 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
408 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
409 else
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
410 mp_msg(MSGT_DEMUX, MSGL_ERR, "Unsupported seek type\n");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
411 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
412
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
413 static int demux_rtp_control(struct demuxer_st *demuxer, int cmd, void *arg)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
414 {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
415 Nemesi_DemuxerStreamData * ndsd = demuxer->priv;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
416 rtsp_ctrl * ctl = ndsd->rtsp;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
417 sdp_attr * r_attr = NULL;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
418 sdp_range r = {0, 0};
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
419 double time = ndsd->time[NEMESI_SESSION_VIDEO] ?
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
420 ndsd->time[NEMESI_SESSION_VIDEO] :
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
421 ndsd->time[NEMESI_SESSION_AUDIO];
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
422
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
423 if (!ctl->rtsp_queue)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
424 return DEMUXER_CTRL_DONTKNOW;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
425
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
426 r_attr = sdp_get_attr(ctl->rtsp_queue->info->attr_list, "range");
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
427 if (r_attr)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
428 r = sdp_parse_range(r_attr->value);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
429
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
430 switch (cmd) {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
431 case DEMUXER_CTRL_GET_TIME_LENGTH:
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
432 if (r.end == 0)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
433 return DEMUXER_CTRL_DONTKNOW;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
434
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
435 *((double *)arg) = ((double)r.end) - ((double)r.begin);
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
436 return DEMUXER_CTRL_OK;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
437
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
438 case DEMUXER_CTRL_GET_PERCENT_POS:
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
439 if (r.end == 0)
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
440 return DEMUXER_CTRL_DONTKNOW;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
441
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
442 *((int *)arg) = (int)( time * 100 / (r.end - r.begin) );
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
443 return DEMUXER_CTRL_OK;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
444 default:
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
445 return DEMUXER_CTRL_DONTKNOW;
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
446 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
447 }
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
448
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
449 demuxer_desc_t demuxer_desc_rtp = {
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
450 "libNemesi demuxer",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
451 "rtp",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
452 "",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
453 "Alessandro Molina",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
454 "requires libNemesi",
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
455 DEMUXER_TYPE_RTP,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
456 0, // no autodetect
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
457 NULL,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
458 demux_rtp_fill_buffer,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
459 demux_open_rtp,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
460 demux_close_rtp,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
461 demux_seek_rtp,
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
462 demux_rtp_control
e4a38a7cdb81 libnemesi support, yet another rtsp/rtp library...
lu_zero
parents:
diff changeset
463 };