summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
Diffstat (limited to 'stream')
-rw-r--r--stream/Makefile151
-rw-r--r--stream/ai_alsa.c166
-rw-r--r--stream/ai_alsa1x.c185
-rw-r--r--stream/ai_oss.c139
-rw-r--r--stream/asf_mmst_streaming.c665
-rw-r--r--stream/asf_streaming.c882
-rw-r--r--stream/audio_in.c219
-rw-r--r--stream/audio_in.h75
-rw-r--r--stream/cache2.c367
-rw-r--r--stream/cdd.h77
-rw-r--r--stream/cdda.c391
-rw-r--r--stream/cddb.c878
-rw-r--r--stream/cdinfo.c137
-rw-r--r--stream/cookies.c278
-rw-r--r--stream/cookies.h16
-rw-r--r--stream/cue_read.c604
-rw-r--r--stream/cue_read.h7
-rw-r--r--stream/dvb_tune.c791
-rw-r--r--stream/dvbin.c870
-rw-r--r--stream/dvbin.h118
-rw-r--r--stream/dvdnav_stream.c396
-rw-r--r--stream/dvdnav_stream.h46
-rw-r--r--stream/freesdp/common.c226
-rw-r--r--stream/freesdp/common.h352
-rw-r--r--stream/freesdp/errorlist.c72
-rw-r--r--stream/freesdp/parser.c1958
-rw-r--r--stream/freesdp/parser.h728
-rw-r--r--stream/freesdp/parserpriv.h118
-rw-r--r--stream/freesdp/priv.h274
-rw-r--r--stream/frequencies.c1169
-rw-r--r--stream/frequencies.h111
-rw-r--r--stream/http.c948
-rw-r--r--stream/http.h52
-rw-r--r--stream/librtsp/rtsp.c804
-rw-r--r--stream/librtsp/rtsp.h84
-rw-r--r--stream/librtsp/rtsp_rtp.c700
-rw-r--r--stream/librtsp/rtsp_rtp.h41
-rw-r--r--stream/librtsp/rtsp_session.c269
-rw-r--r--stream/librtsp/rtsp_session.h42
-rw-r--r--stream/mf.c153
-rw-r--r--stream/mf.h19
-rw-r--r--stream/netstream.h136
-rw-r--r--stream/network.c657
-rw-r--r--stream/network.h68
-rw-r--r--stream/open.c49
-rw-r--r--stream/pnm.c921
-rw-r--r--stream/realrtsp/asmrp.c677
-rw-r--r--stream/realrtsp/asmrp.h45
-rw-r--r--stream/realrtsp/real.c612
-rw-r--r--stream/realrtsp/real.h56
-rw-r--r--stream/realrtsp/rmff.c907
-rw-r--r--stream/realrtsp/rmff.h270
-rw-r--r--stream/realrtsp/sdpplin.c366
-rw-r--r--stream/realrtsp/sdpplin.h109
-rw-r--r--stream/realrtsp/xbuffer.c102
-rw-r--r--stream/realrtsp/xbuffer.h26
-rw-r--r--stream/rtp.c434
-rw-r--r--stream/rtp.h38
-rw-r--r--stream/stream.c434
-rw-r--r--stream/stream.h301
-rw-r--r--stream/stream_dvd.c851
-rw-r--r--stream/stream_dvd.h48
-rw-r--r--stream/stream_file.c162
-rw-r--r--stream/stream_ftp.c469
-rw-r--r--stream/stream_livedotcom.c119
-rw-r--r--stream/stream_netstream.c308
-rw-r--r--stream/stream_null.c45
-rw-r--r--stream/stream_pvr.c1026
-rw-r--r--stream/stream_rtsp.c176
-rw-r--r--stream/stream_smb.c148
-rw-r--r--stream/stream_vcd.c152
-rw-r--r--stream/stream_vstream.c180
-rw-r--r--stream/tv.c919
-rw-r--r--stream/tv.h200
-rw-r--r--stream/tvi_bsdbt848.c846
-rw-r--r--stream/tvi_def.h61
-rw-r--r--stream/tvi_dummy.c120
-rw-r--r--stream/tvi_v4l.c1759
-rw-r--r--stream/tvi_v4l2.c1746
-rw-r--r--stream/url.c373
-rw-r--r--stream/url.h32
-rw-r--r--stream/vcd_read.h245
-rw-r--r--stream/vcd_read_darwin.h212
-rw-r--r--stream/vcd_read_fbsd.h138
-rw-r--r--stream/vcd_read_nbsd.h199
85 files changed, 32320 insertions, 0 deletions
diff --git a/stream/Makefile b/stream/Makefile
new file mode 100644
index 0000000000..5815c3b0c5
--- /dev/null
+++ b/stream/Makefile
@@ -0,0 +1,151 @@
+
+LIBNAME = stream.a
+
+include ../config.mak
+
+# Core
+SRCS += mf.c \
+ open.c \
+ url.c \
+
+ifeq ($(STREAM_CACHE),yes)
+SRCS += cache2.c
+endif
+
+# Miscellaneous
+SRCS += cdinfo.c \
+ cue_read.c \
+
+ifeq ($(CDDA),yes)
+SRCS += cdda.c
+ ifeq ($(MPLAYER_NETWORK),yes)
+ SRCS += cddb.c
+ endif
+endif
+
+# Stream readers/writers
+SRCS += stream.c \
+ stream_file.c \
+ stream_null.c \
+
+ifeq ($(HAVE_DVD),yes)
+SRCS += stream_dvd.c
+endif
+ifeq ($(DVDNAV),yes)
+SRCS += dvdnav_stream.c
+endif
+ifeq ($(VCD),yes)
+SRCS += stream_vcd.c
+endif
+ifeq ($(FTP),yes)
+SRCS += stream_ftp.c
+endif
+ifeq ($(LIBSMBCLIENT),yes)
+SRCS += stream_smb.c
+endif
+ifeq ($(MPLAYER_NETWORK),yes)
+ SRCS += stream_netstream.c
+ ifeq ($(STREAMING_LIVE555),yes)
+ SRCS += stream_livedotcom.c
+ endif
+endif
+ifeq ($(VSTREAM),yes)
+SRCS += stream_vstream.c
+endif
+
+# TV in
+ifeq ($(TV),yes)
+SRCS += tv.c frequencies.c tvi_dummy.c
+ ifeq ($(TV_BSDBT848),yes)
+ SRCS += tvi_bsdbt848.c
+ endif
+ ifeq ($(TV_V4L2),yes)
+ SRCS += tvi_v4l2.c audio_in.c
+ ifeq ($(PVR),yes)
+ SRCS += stream_pvr.c
+ endif
+ endif
+ ifeq ($(TV_V4L1),yes)
+ SRCS += tvi_v4l.c audio_in.c
+ endif
+ ifeq ($(TV_V4L),yes)
+ ifeq ($(ALSA1X),yes)
+ SRCS += ai_alsa1x.c
+ endif
+ ifeq ($(ALSA9),yes)
+ SRCS += ai_alsa.c
+ endif
+ ifeq ($(OSS),yes)
+ SRCS += ai_oss.c
+ endif
+ endif
+endif
+
+ifeq ($(MPLAYER_NETWORK),yes)
+SRCS += asf_streaming.c \
+ http.c \
+ network.c \
+ cookies.c \
+ asf_mmst_streaming.c \
+ pnm.c \
+ rtp.c \
+ stream_rtsp.c \
+
+SRCS += realrtsp/asmrp.c \
+ realrtsp/real.c \
+ realrtsp/rmff.c \
+ realrtsp/sdpplin.c \
+ realrtsp/xbuffer.c \
+
+SRCS += librtsp/rtsp.c \
+ librtsp/rtsp_rtp.c \
+ librtsp/rtsp_session.c \
+
+SRCS += freesdp/common.c \
+ freesdp/errorlist.c \
+ freesdp/parser.c \
+
+endif
+
+ifeq ($(DVBIN),yes)
+SRCS += dvbin.c
+SRCS += dvb_tune.c
+endif
+
+OBJS = $(SRCS:.c=.o)
+INCLUDE = -I.. -I../libmpdemux -I../loader $(LIBAV_INC)
+CFLAGS = $(OPTFLAGS) $(INCLUDE) $(XMMS_CFLAGS)
+
+.SUFFIXES: .c .o
+
+# .PHONY: all clean
+
+all: $(LIBNAME)
+
+.c.o:
+ $(CC) -c $(CFLAGS) -o $@ $<
+
+$(LIBNAME): $(OBJS)
+ $(AR) r $(LIBNAME) $(OBJS)
+ $(RANLIB) $(LIBNAME)
+
+clean:
+ rm -f *.o *.a *~ \
+ realrtsp/*.o realrtsp/*.a realrtsp/*~ \
+ librtsp/*.o librtsp/*.a librtsp/*~ \
+ freesdp/*.o freesdp/*.a freesdp/*~
+
+distclean: clean
+ rm -f .depend test
+
+dep: depend
+
+depend:
+ $(CC) -MM $(CFLAGS) test.c $(SRCS) 1>.depend
+
+#
+# include dependency files if they exist
+#
+ifneq ($(wildcard .depend),)
+include .depend
+endif
diff --git a/stream/ai_alsa.c b/stream/ai_alsa.c
new file mode 100644
index 0000000000..a1468bed09
--- /dev/null
+++ b/stream/ai_alsa.c
@@ -0,0 +1,166 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+#include "config.h"
+
+#include <alsa/asoundlib.h>
+#include "audio_in.h"
+#include "mp_msg.h"
+#include "help_mp.h"
+
+int ai_alsa_setup(audio_in_t *ai)
+{
+ snd_pcm_hw_params_t *params;
+ snd_pcm_sw_params_t *swparams;
+ int buffer_size;
+ int err;
+ unsigned int rate;
+
+ snd_pcm_hw_params_alloca(&params);
+ snd_pcm_sw_params_alloca(&swparams);
+
+ err = snd_pcm_hw_params_any(ai->alsa.handle, params);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_PcmBrokenConfig);
+ return -1;
+ }
+ err = snd_pcm_hw_params_set_access(ai->alsa.handle, params,
+ SND_PCM_ACCESS_RW_INTERLEAVED);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableAccessType);
+ return -1;
+ }
+ err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableSampleFmt);
+ return -1;
+ }
+ err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
+ if (err < 0) {
+ ai->channels = snd_pcm_hw_params_get_channels(params);
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableChanCount,
+ ai->channels);
+ } else {
+ ai->channels = ai->req_channels;
+ }
+
+ err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, ai->req_samplerate, 0);
+ assert(err >= 0);
+ rate = err;
+ ai->samplerate = rate;
+
+ ai->alsa.buffer_time = 1000000;
+ ai->alsa.buffer_time = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
+ ai->alsa.buffer_time, 0);
+ assert(ai->alsa.buffer_time >= 0);
+ ai->alsa.period_time = ai->alsa.buffer_time / 4;
+ ai->alsa.period_time = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
+ ai->alsa.period_time, 0);
+ assert(ai->alsa.period_time >= 0);
+ err = snd_pcm_hw_params(ai->alsa.handle, params);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_CannotInstallHWParams);
+ snd_pcm_hw_params_dump(params, ai->alsa.log);
+ return -1;
+ }
+ ai->alsa.chunk_size = snd_pcm_hw_params_get_period_size(params, 0);
+ buffer_size = snd_pcm_hw_params_get_buffer_size(params);
+ if (ai->alsa.chunk_size == buffer_size) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_PeriodEqualsBufferSize, ai->alsa.chunk_size, (long)buffer_size);
+ return -1;
+ }
+ snd_pcm_sw_params_current(ai->alsa.handle, swparams);
+ err = snd_pcm_sw_params_set_sleep_min(ai->alsa.handle, swparams,0);
+ assert(err >= 0);
+ err = snd_pcm_sw_params_set_avail_min(ai->alsa.handle, swparams, ai->alsa.chunk_size);
+ assert(err >= 0);
+
+ err = snd_pcm_sw_params_set_start_threshold(ai->alsa.handle, swparams, 0);
+ assert(err >= 0);
+ err = snd_pcm_sw_params_set_stop_threshold(ai->alsa.handle, swparams, buffer_size);
+ assert(err >= 0);
+
+ assert(err >= 0);
+ if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_CannotInstallSWParams);
+ snd_pcm_sw_params_dump(swparams, ai->alsa.log);
+ return -1;
+ }
+
+ if (mp_msg_test(MSGT_TV, MSGL_V)) {
+ snd_pcm_dump(ai->alsa.handle, ai->alsa.log);
+ }
+
+ ai->alsa.bits_per_sample = snd_pcm_format_physical_width(SND_PCM_FORMAT_S16_LE);
+ ai->alsa.bits_per_frame = ai->alsa.bits_per_sample * ai->channels;
+ ai->blocksize = ai->alsa.chunk_size * ai->alsa.bits_per_frame / 8;
+ ai->samplesize = ai->alsa.bits_per_sample;
+ ai->bytes_per_sample = ai->alsa.bits_per_sample/8;
+
+ return 0;
+}
+
+int ai_alsa_init(audio_in_t *ai)
+{
+ int err;
+
+ err = snd_pcm_open(&ai->alsa.handle, ai->alsa.device, SND_PCM_STREAM_CAPTURE, 0);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_ErrorOpeningAudio, snd_strerror(err));
+ return -1;
+ }
+
+ err = snd_output_stdio_attach(&ai->alsa.log, stderr, 0);
+
+ if (err < 0) {
+ return -1;
+ }
+
+ err = ai_alsa_setup(ai);
+
+ return err;
+}
+
+#ifndef timersub
+#define timersub(a, b, result) \
+do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+} while (0)
+#endif
+
+int ai_alsa_xrun(audio_in_t *ai)
+{
+ snd_pcm_status_t *status;
+ int res;
+
+ snd_pcm_status_alloca(&status);
+ if ((res = snd_pcm_status(ai->alsa.handle, status))<0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaStatusError, snd_strerror(res));
+ return -1;
+ }
+ if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
+ struct timeval now, diff, tstamp;
+ gettimeofday(&now, 0);
+ snd_pcm_status_get_trigger_tstamp(status, &tstamp);
+ timersub(&now, &tstamp, &diff);
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaXRUN,
+ diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
+ if (mp_msg_test(MSGT_TV, MSGL_V)) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaStatus);
+ snd_pcm_status_dump(status, ai->alsa.log);
+ }
+ if ((res = snd_pcm_prepare(ai->alsa.handle))<0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaXRUNPrepareError, snd_strerror(res));
+ return -1;
+ }
+ return 0; /* ok, data should be accepted again */
+ }
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_AlsaReadWriteError);
+ return -1;
+}
diff --git a/stream/ai_alsa1x.c b/stream/ai_alsa1x.c
new file mode 100644
index 0000000000..d0c6af0f98
--- /dev/null
+++ b/stream/ai_alsa1x.c
@@ -0,0 +1,185 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+#include "config.h"
+
+#include <alsa/asoundlib.h>
+#include "audio_in.h"
+#include "mp_msg.h"
+#include "help_mp.h"
+
+int ai_alsa_setup(audio_in_t *ai)
+{
+ snd_pcm_hw_params_t *params;
+ snd_pcm_sw_params_t *swparams;
+ snd_pcm_uframes_t buffer_size, period_size;
+ int err;
+ int dir;
+ unsigned int rate;
+
+ snd_pcm_hw_params_alloca(&params);
+ snd_pcm_sw_params_alloca(&swparams);
+
+ err = snd_pcm_hw_params_any(ai->alsa.handle, params);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_PcmBrokenConfig);
+ return -1;
+ }
+
+ err = snd_pcm_hw_params_set_access(ai->alsa.handle, params,
+ SND_PCM_ACCESS_RW_INTERLEAVED);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableAccessType);
+ return -1;
+ }
+
+ err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableSampleFmt);
+ return -1;
+ }
+
+ err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
+ if (err < 0) {
+ snd_pcm_hw_params_get_channels(params, &ai->channels);
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_UnavailableChanCount,
+ ai->channels);
+ } else {
+ ai->channels = ai->req_channels;
+ }
+
+ dir = 0;
+ rate = ai->req_samplerate;
+ err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, &rate, &dir);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA1X_CannotSetSamplerate);
+ }
+ ai->samplerate = rate;
+
+ dir = 0;
+ ai->alsa.buffer_time = 1000000;
+ err = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
+ &ai->alsa.buffer_time, &dir);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA1X_CannotSetBufferTime);
+ }
+
+ dir = 0;
+ ai->alsa.period_time = ai->alsa.buffer_time / 4;
+ err = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
+ &ai->alsa.period_time, &dir);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA1X_CannotSetPeriodTime);
+ }
+
+ err = snd_pcm_hw_params(ai->alsa.handle, params);
+ if (err < 0) {
+ mp_msg(MSGT_TV, MSGL_ERR, MSGTR_MPDEMUX_AIALSA_CannotInstallHWParams, snd_strerror(err));
+ snd_pcm_hw_params_dump(params, ai->alsa.log);
+ return -1;
+ }
+
+ dir = -1;
+ snd_pcm_hw_params_get_period_size(params, &period_size, &dir);
+ snd_pcm_hw_params_get_buffer_size(params, &buffer_size);