]> git.sesse.net Git - vlc/commitdiff
DTV: support for BDA (untested) on Windows
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 26 Mar 2011 16:30:03 +0000 (18:30 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 26 Mar 2011 16:50:30 +0000 (18:50 +0200)
This merges the Linux DVB and Windows BDA backend behind the same
plugin-internal interface.
Like the existing BDA plugin, this does not support PID filters,
signal levels nor DVB-S2.

configure.ac
modules/access/Modules.am
modules/access/bda/Modules.am [deleted file]
modules/access/bda/bda.c [deleted file]
modules/access/bda/bda.h [deleted file]
modules/access/dtv/bdadefs.h [moved from modules/access/bda/bdadefs.h with 100% similarity]
modules/access/dtv/bdagraph.cpp [moved from modules/access/bda/bdagraph.cpp with 85% similarity]
modules/access/dtv/bdagraph.hpp [moved from modules/access/bda/bdagraph.h with 86% similarity]

index c77d88ac421ce1bae13d39ae5fb0cea8fe61bcdd..9dc8da17f1097d2ca1eece7f11f16c38372a718b 100644 (file)
@@ -1910,24 +1910,6 @@ then
   fi
 fi
 
-dnl
-dnl  Windows DirectShow BDA access module
-dnl
-AC_ARG_ENABLE(bda,
-  AS_HELP_STRING([--enable-bda],[Win32 DirectShow BDA support (default
-                 enabled on Win32)]))
-if test "${enable_bda}" != "no"
-then
-  if test "${SYS}" = "mingw32"
-  then
-      AC_CHECK_HEADERS(dshow.h,
-      [ VLC_ADD_PLUGIN([bda])
-        VLC_ADD_CXXFLAGS([bda],[])
-        VLC_ADD_LIBS([bda],[-lstrmiids -lole32 -loleaut32 -luuid]) ])
-  fi
-fi
-
-
 dnl
 dnl  Blu-ray Disc Support with libbluray
 dnl
@@ -4270,7 +4252,6 @@ AC_CONFIG_FILES([
   test/Makefile
   modules/access/Makefile
   modules/access/bd/Makefile
-  modules/access/bda/Makefile
   modules/access/dshow/Makefile
   modules/access/dvb/Makefile
   modules/access/mms/Makefile
index 8daeef1610fc34abf22fca3df608038233babe49..7b7e285e2d49a30968429e8aaf9bade0c1a2d5b5 100644 (file)
@@ -4,12 +4,12 @@
 LIBTOOL=@LIBTOOL@ --tag=CC
 
 BASE_SUBDIRS = dvb mms rtp rtsp vcd vcdx screen bd zip
-EXTRA_SUBDIRS = bda dshow
+EXTRA_SUBDIRS = dshow
 SUBDIRS = $(BASE_SUBDIRS)
 DIST_SUBDIRS = $(BASE_SUBDIRS) $(EXTRA_SUBDIRS)
 
 if HAVE_WIN32
-SUBDIRS += bda dshow
+SUBDIRS += dshow
 endif
 
 libfilesystem_plugin_la_SOURCES = \
@@ -116,18 +116,37 @@ if HAVE_XCB
 libvlc_LTLIBRARIES += libxcb_screen_plugin.la
 endif
 
-# Digital TV
+
+### Digital TV ###
+
 libdtv_plugin_la_SOURCES = \
        dtv/dtv.h \
        dtv/access.c
 libdtv_plugin_la_CFLAGS = $(AM_CFLAGS)
 libdtv_plugin_la_LIBADD = $(AM_LIBADD)
 libdtv_plugin_la_DEPENDENCIES =
+
 if HAVE_LINUX
 libdtv_plugin_la_SOURCES += dtv/linux.c
 libvlc_LTLIBRARIES += libdtv_plugin.la
 endif
 
+if HAVE_WIN32
+# Work-around automake bug:
+# Use an import library for C++ to retain C linker on other platforms.
+libbda_la_SOURCES = dtv/bdadefs.h dtv/bdagraph.cpp dtv/bdagraph.hpp
+libbda_la_CXXFLAGS = $(AM_CXXFLAGS)
+libbda_la_LDFLAGS = -static
+libbda_la_LIBADD = -lstrmiids -lole32 -loleaut32 -luuid
+noinst_LTLIBRARIES = libbda.la
+
+libdtv_plugin_la_DEPENDENCIES += libbda.la
+libdtv_plugin_la_LIBADD += libbda.la -lstdc++
+libvlc_LTLIBRARIES += libdtv_plugin.la
+endif
+
+
+
 EXTRA_LTLIBRARIES += \
        libaccess_rtmp_plugin.la \
        libaccess_shm_plugin.la
diff --git a/modules/access/bda/Modules.am b/modules/access/bda/Modules.am
deleted file mode 100644 (file)
index df038ce..0000000
+++ /dev/null
@@ -1 +0,0 @@
-SOURCES_bda = bda.c bda.h bdagraph.h bdagraph.cpp bdadefs.h
diff --git a/modules/access/bda/bda.c b/modules/access/bda/bda.c
deleted file mode 100644 (file)
index f5c3dc2..0000000
+++ /dev/null
@@ -1,528 +0,0 @@
-/*****************************************************************************
- * bda.c : BDA access module for vlc
- *****************************************************************************
- * Copyright (C) 2007-2009 the VideoLAN team
- *
- * Author: Ken Self <kenself(at)optusnet(dot)com(dot)au>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "bda.h"
-
-#include <vlc_plugin.h>
-
-
-/*****************************************************************************
- * Access: local prototypes
- *****************************************************************************/
-static int  Open( vlc_object_t *p_this );
-static int  ParsePath( access_t *p_access, const char* psz_module,
-    const int i_param_count, const char** psz_param, const int* i_type );
-static void Close( vlc_object_t *p_this );
-static block_t *Block( access_t * );
-static int Control( access_t *, int, va_list );
-
-#define CACHING_TEXT N_("Caching value in ms")
-#define CACHING_LONGTEXT N_( \
-    "Caching value for DVB streams. This " \
-    "value should be set in milliseconds." )
-
-#define ADAPTER_TEXT N_("Adapter card to tune")
-#define ADAPTER_LONGTEXT ADAPTER_TEXT
-
-#define FREQ_TEXT N_("Transponder/multiplex frequency")
-#define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")
-
-#define INVERSION_TEXT N_("Inversion mode")
-#define INVERSION_LONGTEXT N_("Inversion mode [0=off, 1=on, 2=auto]")
-static const int i_inversion_list[] = { -1, 0, 1, 2 };
-static const char *const ppsz_inversion_text[] = { N_("Undefined"), N_("Off"),
-    N_("On"), N_("Auto") };
-
-/* Satellite */
-#define NETID_TEXT N_("Network Identifier")
-#define NETID_LONGTEXT NULL
-
-#define SRATE_TEXT N_("Transponder symbol rate in kHz")
-#define SRATE_LONGTEXT NULL
-
-#define LNB_LOF1_TEXT N_("Antenna lnb_lof1 (kHz)")
-#define LNB_LOF1_LONGTEXT N_("Low Band Local Osc Freq in kHz (usually 9.75GHz)")
-
-#define LNB_LOF2_TEXT N_("Antenna lnb_lof2 (kHz)")
-#define LNB_LOF2_LONGTEXT N_("High Band Local Osc Freq in kHz (usually 10.6GHz)")
-
-#define LNB_SLOF_TEXT N_("Antenna lnb_slof (kHz)")
-#define LNB_SLOF_LONGTEXT N_( \
-    "Low Noise Block switch freq in kHz (usually 11.7GHz)")
-
-/* Cable */
-#define MODULATION_TEXT N_("Modulation type")
-#define MODULATION_LONGTEXT N_("QAM, PSK or VSB modulation method")
-static const int i_mod_list[] = { -1, 16, 32, 64, 128, 256,
-    10002, 10004, 20008, 20016 };
-static const char *const ppsz_mod_text[] = {
-    N_("Undefined"), N_("QAM16"), N_("QAM32"), N_("QAM64"), N_("QAM128"), N_("QAM256"),
-    N_("BPSK"), N_("QPSK"), N_("8VSB"), N_("16VSB") };
-
-/* ATSC */
-#define MAJOR_CHANNEL_TEXT N_("ATSC Major Channel")
-#define MAJOR_CHANNEL_LONGTEXT N_("ATSC Major Channel")
-#define MINOR_CHANNEL_TEXT N_("ATSC Minor Channel")
-#define MINOR_CHANNEL_LONGTEXT N_("ATSC Minor Channel")
-#define PHYSICAL_CHANNEL_TEXT N_("ATSC Physical Channel")
-#define PHYSICAL_CHANNEL_LONGTEXT N_("ATSC Physical Channel")
-
-/* Terrestrial */
-#define CODE_RATE_HP_TEXT N_("FEC rate")
-#define CODE_RATE_HP_LONGTEXT N_("FEC rate includes " \
-    "DVB-T high priority stream FEC Rate")
-static const int i_hp_fec_list[] = { -1, 1, 2, 3, 4, 5 };
-static const char *const ppsz_hp_fec_text[] = {
-    N_("Undefined"), N_("1/2"), N_("2/3"), N_("3/4"), N_("5/6"), N_("7/8") };
-
-#define CODE_RATE_LP_TEXT N_("Terrestrial low priority stream code rate (FEC)")
-#define CODE_RATE_LP_LONGTEXT N_("Low Priority FEC Rate " \
-    "[Undefined,1/2,2/3,3/4,5/6,7/8]")
-static const int i_lp_fec_list[] = { -1, 1, 2, 3, 4, 5 };
-static const char *const ppsz_lp_fec_text[] = {
-    N_("Undefined"), N_("1/2"), N_("2/3"), N_("3/4"), N_("5/6"), N_("7/8") };
-
-#define BANDWIDTH_TEXT N_("Terrestrial bandwidth")
-#define BANDWIDTH_LONGTEXT N_("Terrestrial bandwidth [0=auto,6,7,8 in MHz]")
-static const int i_band_list[] = { -1, 6, 7, 8 };
-static const char *const ppsz_band_text[] = {
-    N_("Undefined"), N_("6 MHz"), N_("7 MHz"), N_("8 MHz") };
-
-#define GUARD_TEXT N_("Terrestrial guard interval")
-#define GUARD_LONGTEXT N_("Guard interval [Undefined,1/4,1/8,1/16,1/32]")
-static const int i_guard_list[] = { -1, 4, 8, 16, 32 };
-static const char *const ppsz_guard_text[] = {
-    N_("Undefined"), N_("1/4"), N_("1/8"), N_("1/16"), N_("1/32") };
-
-#define TRANSMISSION_TEXT N_("Terrestrial transmission mode")
-#define TRANSMISSION_LONGTEXT N_("Transmission mode [Undefined,2k,8k]")
-static const int i_transmission_list[] = { -1, 2, 8 };
-static const char *const ppsz_transmission_text[] = {
-    N_("Undefined"), N_("2k"), N_("8k") };
-
-#define HIERARCHY_TEXT N_("Terrestrial hierarchy mode")
-#define HIERARCHY_LONGTEXT N_("Hierarchy alpha value [Undefined,1,2,4]")
-static const int i_hierarchy_list[] = { -1, 1, 2, 4 };
-static const char *const ppsz_hierarchy_text[] = {
-    N_("Undefined"), N_("1"), N_("2"), N_("4") };
-
-/* BDA module additional DVB-S Parameters */
-#define AZIMUTH_TEXT N_("Satellite Azimuth")
-#define AZIMUTH_LONGTEXT N_("Satellite Azimuth in tenths of degree")
-#define ELEVATION_TEXT N_("Satellite Elevation")
-#define ELEVATION_LONGTEXT N_("Satellite Elevation in tenths of degree")
-#define LONGITUDE_TEXT N_("Satellite Longitude")
-#define LONGITUDE_LONGTEXT N_( \
-    "Satellite Longitude in 10ths of degree, -ve=West")
-#define POLARISATION_TEXT N_("Satellite Polarisation")
-#define POLARISATION_LONGTEXT N_("Satellite Polarisation [H/V/L/R]")
-static const char *const ppsz_polar_list[] = { "H", "V", "L", "R" };
-static const char *const ppsz_polar_text[] = {
-    N_("Horizontal"), N_("Vertical"),
-    N_("Circular Left"), N_("Circular Right") };
-#define RANGE_TEXT N_("Satellite Range Code")
-#define RANGE_LONGTEXT N_("Satellite Range Code as defined by manufacturer " \
-   "e.g. DISEqC switch code")
-#define NAME_TEXT N_("Network Name")
-#define NAME_LONGTEXT N_("Unique network name in the System Tuning Spaces")
-#define CREATE_TEXT N_("Network Name to Create")
-#define CREATE_LONGTEXT N_("Create Unique name in the System Tuning Spaces")
-
-vlc_module_begin ()
-    set_shortname( N_("DVB") )
-    set_description( N_("DirectShow DVB input") )
-    set_category( CAT_INPUT )
-    set_subcategory( SUBCAT_INPUT_ACCESS )
-
-    add_integer( "dvb-caching", DEFAULT_PTS_DELAY / 1000, CACHING_TEXT,
-                 CACHING_LONGTEXT, true )
-        change_safe()
-    add_integer( "dvb-frequency", 0, FREQ_TEXT, FREQ_LONGTEXT,
-                 false )
-        change_safe()
-        add_string( "dvb-network-name", NULL, NAME_TEXT, NAME_LONGTEXT,
-                    true )
-        add_string( "dvb-create-name", NULL, CREATE_TEXT,
-                    CREATE_LONGTEXT, true )
-        add_integer( "dvb-adapter", -1, ADAPTER_TEXT, ADAPTER_LONGTEXT,
-                     true )
-
-    /* DVB-S (satellite) */
-    add_integer( "dvb-inversion", 2, INVERSION_TEXT,
-        INVERSION_LONGTEXT, true )
-        change_integer_list( i_inversion_list, ppsz_inversion_text )
-        add_string( "dvb-polarisation", NULL, POLARISATION_TEXT,
-            POLARISATION_LONGTEXT, false )
-            change_string_list( ppsz_polar_list, ppsz_polar_text, 0 )
-            /* Note: Polaristion H = voltage 18; V = voltage 13; */
-        add_integer( "dvb-network-id", 0, NETID_TEXT, NETID_LONGTEXT,
-            true )
-        add_integer( "dvb-azimuth", 0, AZIMUTH_TEXT, AZIMUTH_LONGTEXT,
-            true )
-        add_integer( "dvb-elevation", 0, ELEVATION_TEXT,
-            ELEVATION_LONGTEXT, true )
-        add_integer( "dvb-longitude", 0, LONGITUDE_TEXT,
-            LONGITUDE_LONGTEXT, true )
-        add_string( "dvb-range", NULL, RANGE_TEXT,
-            RANGE_LONGTEXT, true )
-        /* dvb-range corresponds to the BDA InputRange parameter which is
-         * used by some drivers to control the diseqc */
-    add_integer( "dvb-lnb-lof1", 0, LNB_LOF1_TEXT,
-        LNB_LOF1_LONGTEXT, true )
-    add_integer( "dvb-lnb-lof2", 0, LNB_LOF2_TEXT,
-        LNB_LOF2_LONGTEXT, true )
-    add_integer( "dvb-lnb-slof", 0, LNB_SLOF_TEXT,
-        LNB_SLOF_LONGTEXT, true )
-    add_integer( "dvb-srate", 27500, SRATE_TEXT, SRATE_LONGTEXT,
-        false )
-
-    /* DVB-C (cable) */
-    add_integer( "dvb-modulation", -1, MODULATION_TEXT,
-        MODULATION_LONGTEXT, true )
-        change_integer_list( i_mod_list, ppsz_mod_text )
-
-    /* ATSC */
-    add_integer( "dvb-major-channel", 0, MAJOR_CHANNEL_TEXT,
-        MAJOR_CHANNEL_LONGTEXT, true )
-     add_integer( "dvb-minor-channel", 0, MINOR_CHANNEL_TEXT,
-        MINOR_CHANNEL_LONGTEXT, true )
-     add_integer( "dvb-physical-channel", 0, PHYSICAL_CHANNEL_TEXT,
-        PHYSICAL_CHANNEL_LONGTEXT, true )
-
-    /* DVB-T (terrestrial) */
-    add_integer( "dvb-code-rate-hp", -1, CODE_RATE_HP_TEXT,
-        CODE_RATE_HP_LONGTEXT, true )
-        change_integer_list( i_hp_fec_list, ppsz_hp_fec_text )
-    add_integer( "dvb-code-rate-lp", -1, CODE_RATE_LP_TEXT,
-        CODE_RATE_LP_LONGTEXT, true )
-        change_integer_list( i_lp_fec_list, ppsz_lp_fec_text )
-    add_integer( "dvb-bandwidth", 0, BANDWIDTH_TEXT, BANDWIDTH_LONGTEXT,
-        false )
-        change_integer_list( i_band_list, ppsz_band_text )
-        change_safe()
-    add_integer( "dvb-guard", -1, GUARD_TEXT, GUARD_LONGTEXT, true )
-        change_integer_list( i_guard_list, ppsz_guard_text )
-    add_integer( "dvb-transmission", -1, TRANSMISSION_TEXT,
-        TRANSMISSION_LONGTEXT, true )
-        change_integer_list( i_transmission_list, ppsz_transmission_text )
-    add_integer( "dvb-hierarchy", -1, HIERARCHY_TEXT, HIERARCHY_LONGTEXT,
-        true )
-        change_integer_list( i_hierarchy_list, ppsz_hierarchy_text )
-
-    set_capability( "access", 0 )
-    add_shortcut( "dvb",                  /* Generic name */
-                  "dvb-s", "dvbs",        /* Satellite */
-                  "dvb-c", "dvbc",        /* Cable */
-                  "dvb-t", "dvbt",        /* Terrestrial */
-                  "atsc",                 /* Atsc */
-                  "cqam",)                /* Clear QAM */
-
-    set_callbacks( Open, Close )
-vlc_module_end ()
-
-/*****************************************************************************
- * Open: open direct show device as an access module
- *****************************************************************************/
-static int Open( vlc_object_t *p_this )
-{
-    access_t     *p_access = (access_t*)p_this;
-    access_sys_t *p_sys;
-    const char* psz_module  = "dvb";
-    const int   i_param_count = 26;
-    const char* psz_param[] = { "frequency", "bandwidth",
-        "srate", "azimuth", "elevation", "longitude", "polarisation",
-        "modulation", "caching", "lnb-lof1", "lnb-lof2", "lnb-slof",
-        "inversion", "network-id", "code-rate-hp", "code-rate-lp",
-        "guard", "transmission", "hierarchy", "range", "network-name",
-        "create-name", "major-channel", "minor-channel", "physical-channel",
-        "adapter" };
-
-    const int   i_type[] = { VLC_VAR_INTEGER, VLC_VAR_INTEGER,
-        VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
-        VLC_VAR_STRING, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
-        VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
-        VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER,
-        VLC_VAR_INTEGER, VLC_VAR_STRING, VLC_VAR_STRING, VLC_VAR_STRING,
-        VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER, VLC_VAR_INTEGER };
-
-    char  psz_full_name[128];
-    int i_ret;
-
-   /* Only if selected */
-    if( *p_access->psz_access == '\0' )
-        return VLC_EGENERIC;
-
-    /* Setup Access */
-    p_access->pf_read = NULL;
-    p_access->pf_block = Block;     /* Function to read compressed data */
-    p_access->pf_control = Control; /* Function to control the module */
-    p_access->pf_seek = NULL;
-    p_access->info.i_update = 0;
-    p_access->info.i_size = 0;
-    p_access->info.i_pos = 0;
-    p_access->info.b_eof = false;
-    p_access->info.i_title = 0;
-    p_access->info.i_seekpoint = 0;
-    p_access->p_sys = p_sys = calloc( 1, sizeof( access_sys_t ) );
-    if( !p_sys )
-        return VLC_ENOMEM;
-
-    for( int i = 0; i < i_param_count; i++ )
-    {
-        snprintf( psz_full_name, 128, "%s-%s", psz_module,
-                  psz_param[i] );
-        var_Create( p_access, psz_full_name, i_type[i] | VLC_VAR_DOINHERIT );
-    }
-
-    /* Parse the command line */
-    if( ParsePath( p_access, psz_module, i_param_count, psz_param, i_type ) )
-    {
-        free( p_sys );
-        return VLC_EGENERIC;
-    }
-
-    /* Build directshow graph */
-    dvb_newBDAGraph( p_access );
-
-    i_ret = VLC_EGENERIC;
-
-    if( strncmp( p_access->psz_access, "dvb-s", 5 ) == 0 ||
-        strncmp( p_access->psz_access, "dvbs", 4 ) == 0 )
-    {
-        i_ret = dvb_SubmitDVBSTuneRequest( p_access );
-    }
-    if( strncmp( p_access->psz_access, "dvb-c", 5 ) == 0  ||
-        strncmp( p_access->psz_access, "dvbc", 4 ) == 0 )
-    {
-        i_ret = dvb_SubmitDVBCTuneRequest( p_access );
-    }
-    if( strncmp( p_access->psz_access, "dvb-t", 5 ) == 0 ||
-        strncmp( p_access->psz_access, "dvbt", 4 ) == 0 )
-    {
-        i_ret = dvb_SubmitDVBTTuneRequest( p_access );
-    }
-    if( strncmp( p_access->psz_access, "atsc", 4 ) == 0 )
-    {
-        i_ret = dvb_SubmitATSCTuneRequest( p_access );
-    }
-    if( strncmp( p_access->psz_access, "cqam", 4 ) == 0 )
-    {
-        i_ret = dvb_SubmitCQAMTuneRequest( p_access );
-    }
-    if( !strcmp( p_access->psz_access, "dvb" ) )
-    {
-        /* Try to auto detect */
-        if( i_ret )
-            i_ret = dvb_SubmitDVBSTuneRequest( p_access );
-        if( i_ret )
-            i_ret = dvb_SubmitDVBCTuneRequest( p_access );
-        if( i_ret )
-            i_ret = dvb_SubmitDVBTTuneRequest( p_access );
-        if( i_ret )
-            i_ret = dvb_SubmitATSCTuneRequest( p_access );
-        if( i_ret )
-            i_ret = dvb_SubmitCQAMTuneRequest( p_access );
-    }
-
-    if( !i_ret )
-    {
-        free( p_access->psz_demux );
-        p_access->psz_demux = strdup( "ts" );
-    }
-    else
-    {
-        msg_Warn( p_access, "DVB_Open: Unsupported Network %s",
-                  p_access->psz_access);
-    }
-    return i_ret;
-}
-
-/*****************************************************************************
- * ParsePath:
- * Parses the path passed to VLC treating it as a MRL which
- * is organized as a sequence of <key>=<value> pairs separated by a colon
- * e.g. :key1=value1:key2=value2:key3=value3.
- * Each <key> is matched to one of the parameters passed in psz_param using
- * whatever characters are provided. e.g. fr = fre = frequency
- *****************************************************************************/
-static int ParsePath( access_t *p_access, const char* psz_module,
-    const int i_param_count, const char** psz_param, const int* i_type )
-{
-    const int   MAXPARAM = 40;
-    bool        b_used[MAXPARAM];
-    char*       psz_parser;
-    char*       psz_token;
-    char*       psz_value;
-    vlc_value_t v_value;
-    size_t      i_token_len, i_param_len;
-    int         i_this_param;
-    char        psz_full_name[128];
-
-    if( i_param_count > MAXPARAM )
-    {
-        msg_Warn( p_access, "ParsePath: Too many parameters: %d > %d",
-            i_param_count, MAXPARAM );
-            return VLC_EGENERIC;
-    }
-    for( int i = 0; i < i_param_count; i++ )
-        b_used[i] = false;
-    psz_parser = p_access->psz_location;
-    if( strlen( psz_parser ) <= 0 )
-        return VLC_SUCCESS;
-
-    i_token_len = strcspn( psz_parser, ":" );
-    if( i_token_len <= 0 )
-        i_token_len  = strcspn( ++psz_parser, ":" );
-
-    do
-    {
-        psz_token = strndup( psz_parser, i_token_len );
-        i_param_len  = strcspn( psz_token, "=" );
-        if( i_param_len <= 0 )
-        {
-            msg_Warn( p_access, "ParsePath: Unspecified parameter %s",
-                psz_token );
-            free( psz_token );
-            return VLC_EGENERIC;
-        }
-        i_this_param = -1;
-        for( int i = 0; i < i_param_count; i++ )
-        {
-            if( strncmp( psz_token, psz_param[i], i_param_len ) == 0 )
-            {
-                i_this_param = i;
-                break;
-            }
-        }
-        if( i_this_param < 0 )
-        {
-            msg_Warn( p_access, "ParsePath: Unknown parameter %s", psz_token );
-            free( psz_token );
-            return VLC_EGENERIC;
-        }
-        if( b_used[i_this_param] )
-        {
-            msg_Warn( p_access, "ParsePath: Duplicate parameter %s",
-                psz_token );
-            free( psz_token );
-            return VLC_EGENERIC;
-        }
-        b_used[i_this_param] = true;
-
-        /* if "=" was found in token then value starts at
-         * psz_token + i_paramlen + 1
-         * else there is no value specified so we use an empty string */
-        psz_value = psz_token + i_param_len + 1;
-        if( i_param_len >= i_token_len )
-            psz_value--;
-        if( i_type[i_this_param] == VLC_VAR_STRING )
-             v_value.psz_string = strdup( psz_value );
-        if( i_type[i_this_param] == VLC_VAR_INTEGER )
-             v_value.i_int = atol( psz_value );
-        snprintf( psz_full_name, 128, "%s-%s", psz_module,
-            psz_param[i_this_param] );
-        var_Set( p_access, psz_full_name, v_value );
-
-        free( psz_token );
-        if( i_token_len >= strlen( psz_parser ) )
-            break;
-        psz_parser += i_token_len + 1;
-        i_token_len = strcspn( psz_parser, ":" );
-    }
-    while( true );
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * AccessClose: close device
- *****************************************************************************/
-static void Close( vlc_object_t *p_this )
-{
-    access_t     *p_access = (access_t *)p_this;
-    access_sys_t *p_sys    = p_access->p_sys;
-
-    dvb_deleteBDAGraph( p_access );
-
-    free( p_sys );
-}
-
-/*****************************************************************************
- * Control:
- *****************************************************************************/
-static int Control( access_t *p_access, int i_query, va_list args )
-{
-    bool   *pb_bool, b_bool;
-    int          i_int;
-    int64_t      *pi_64;
-
-    switch( i_query )
-    {
-    case ACCESS_CAN_SEEK:           /* 0 */
-    case ACCESS_CAN_FASTSEEK:       /* 1 */
-    case ACCESS_CAN_PAUSE:          /* 2 */
-    case ACCESS_CAN_CONTROL_PACE:   /* 3 */
-        pb_bool = (bool*)va_arg( args, bool* );
-        *pb_bool = false;
-        break;
-    case ACCESS_GET_PTS_DELAY:      /* 5 */
-        pi_64 = (int64_t*)va_arg( args, int64_t * );
-        *pi_64 = (int64_t)var_GetInteger( p_access, "dvb-caching" ) * 1000;
-        break;
-        /* */
-    case ACCESS_GET_TITLE_INFO:     /* 6 */
-    case ACCESS_GET_META:           /* 7 */
-    case ACCESS_SET_PAUSE_STATE:    /* 8 */
-    case ACCESS_SET_TITLE:          /* 9 */
-    case ACCESS_SET_SEEKPOINT:      /* 10 */
-    case ACCESS_GET_CONTENT_TYPE:
-        return VLC_EGENERIC;
-
-    case ACCESS_SET_PRIVATE_ID_STATE: /* 11 */
-        i_int  = (int)va_arg( args, int );
-        b_bool = (bool)va_arg( args, int );
-        break;
-    case ACCESS_SET_PRIVATE_ID_CA:  /* 12 -From Demux */
-        return VLC_EGENERIC;
-    default:
-        msg_Warn( p_access,
-                  "DVB_Control: Unimplemented query in control %d", i_query );
-        return VLC_EGENERIC;
-    }
-
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * Block:
- *****************************************************************************/
-static block_t *Block( access_t *p_access )
-{
-    return dvb_Pop( p_access );
-}
diff --git a/modules/access/bda/bda.h b/modules/access/bda/bda.h
deleted file mode 100644 (file)
index 609cf69..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*****************************************************************************
- * bda.h : DirectShow BDA access header for vlc
- *****************************************************************************
- * Copyright ( C ) 2007 the VideoLAN team
- *
- * Author: Ken Self <kens@campoz.fslife.co.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * ( at your option ) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <vlc_common.h>
-#include <vlc_input.h>
-#include <vlc_access.h>
-
-#ifndef _MSC_VER
-#   include <wtypes.h>
-#   include <unknwn.h>
-#   include <ole2.h>
-#   include <limits.h>
-#   ifdef _WINGDI_
-#      undef _WINGDI_
-#   endif
-#   define _WINGDI_ 1
-#   define AM_NOVTABLE
-#   define _OBJBASE_H_
-#   undef _X86_
-#   ifndef _I64_MAX
-#     define _I64_MAX LONG_LONG_MAX
-#   endif
-#   define LONGLONG long long
-#endif
-
-#ifdef __cplusplus
-class BDAGraph;
-extern "C" {
-#else
-typedef struct BDAGraph BDAGraph;
-#endif
-
-void dvb_newBDAGraph( access_t* p_access );
-void dvb_deleteBDAGraph( access_t* p_access );
-int dvb_SubmitCQAMTuneRequest( access_t* p_access );
-int dvb_SubmitATSCTuneRequest( access_t* p_access );
-int dvb_SubmitDVBTTuneRequest( access_t* p_access );
-int dvb_SubmitDVBCTuneRequest( access_t* p_access );
-int dvb_SubmitDVBSTuneRequest( access_t* p_access );
-block_t *dvb_Pop( access_t* p_access );
-
-#ifdef __cplusplus
-}
-#endif
-
-/****************************************************************************
- * Access descriptor declaration
- ****************************************************************************/
-struct access_sys_t
-{
-    BDAGraph *p_bda_module;
-};
similarity index 85%
rename from modules/access/bda/bdagraph.cpp
rename to modules/access/dtv/bdagraph.cpp
index 4864d226d283ed3e5d2acc8062d47efb2f5d1d27..d316fd398f902b236bb3728a657c0a3c7adaf03f 100644 (file)
@@ -1,7 +1,8 @@
 /*****************************************************************************
  * bdagraph.cpp : DirectShow BDA graph for vlc
  *****************************************************************************
- * Copyright( C ) 2007 the VideoLAN team
+ * Copyright (C) 2007 the VideoLAN team
+ * Copyright (C) 2011 Rémi Denis-Courmont
  *
  * Author: Ken Self <kenself(at)optusnet(dot)com(dot)au>
  *
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "bdagraph.h"
-#include <ctype.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
 
-/****************************************************************************
- * Interfaces for calls from C
- ****************************************************************************/
-extern "C" {
+#include <vlc_common.h>
+#include <vlc_block.h>
+#include "dtv/bdagraph.hpp"
+#include "dtv/dtv.h"
 
-    void dvb_newBDAGraph( access_t* p_access )
-    {
-        p_access->p_sys->p_bda_module = new BDAGraph( p_access );
-    };
 
-    void dvb_deleteBDAGraph( access_t* p_access )
-    {
-        delete p_access->p_sys->p_bda_module;
-    };
+static ModulationType dvb_parse_modulation (const char *mod)
+{
+    if (!strcmp (mod, "16QAM"))   return BDA_MOD_16QAM;
+    if (!strcmp (mod, "32QAM"))   return BDA_MOD_32QAM;
+    if (!strcmp (mod, "64QAM"))   return BDA_MOD_64QAM;
+    if (!strcmp (mod, "128QAM"))  return BDA_MOD_128QAM;
+    if (!strcmp (mod, "256QAM"))  return BDA_MOD_256QAM;
+    return BDA_MOD_NOT_SET;
+}
 
-    int dvb_SubmitCQAMTuneRequest( access_t* p_access )
+static BinaryConvolutionCodeRate dvb_parse_fec (uint32_t fec)
+{
+    switch (fec)
     {
-        if( p_access->p_sys->p_bda_module )
-            return p_access->p_sys->p_bda_module->SubmitCQAMTuneRequest();
-        return VLC_EGENERIC;
-    };
+        case VLC_FEC(1,2): return BDA_BCC_RATE_1_2;
+        case VLC_FEC(2,3): return BDA_BCC_RATE_2_3;
+        case VLC_FEC(3,4): return BDA_BCC_RATE_3_4;
+        case VLC_FEC(5,6): return BDA_BCC_RATE_5_6;
+        case VLC_FEC(7,8): return BDA_BCC_RATE_7_8;
+    }
+    return BDA_BCC_RATE_NOT_SET;
+}
 
-    int dvb_SubmitATSCTuneRequest( access_t* p_access )
+static GuardInterval dvb_parse_guard (uint32_t guard)
+{
+    switch (guard)
     {
-        if( p_access->p_sys->p_bda_module )
-            return p_access->p_sys->p_bda_module->SubmitATSCTuneRequest();
-        return VLC_EGENERIC;
-    };
+        case VLC_GUARD(1, 4): return BDA_GUARD_1_4;
+        case VLC_GUARD(1, 8): return BDA_GUARD_1_8;
+        case VLC_GUARD(1,16): return BDA_GUARD_1_16;
+        case VLC_GUARD(1,32): return BDA_GUARD_1_32;
+    }
+    return BDA_GUARD_NOT_SET;
+}
 
-    int dvb_SubmitDVBTTuneRequest( access_t* p_access )
+static TransmissionMode dvb_parse_transmission (int transmit)
+{
+    switch (transmit)
     {
-        if( p_access->p_sys->p_bda_module )
-            return p_access->p_sys->p_bda_module->SubmitDVBTTuneRequest();
-        return VLC_EGENERIC;
-    };
+        case 2: return BDA_XMIT_MODE_2K;
+        case 8: return BDA_XMIT_MODE_8K;
+    }
+    return BDA_XMIT_MODE_NOT_SET;
+}
 
-    int dvb_SubmitDVBCTuneRequest( access_t* p_access )
+static HierarchyAlpha dvb_parse_hierarchy (int hierarchy)
+{
+    switch (hierarchy)
     {
-        if( p_access->p_sys->p_bda_module )
-            return p_access->p_sys->p_bda_module->SubmitDVBCTuneRequest();
-        return VLC_EGENERIC;
-    };
+        case 1: return BDA_HALPHA_1;
+        case 2: return BDA_HALPHA_2;
+        case 4: return BDA_HALPHA_4;
+    }
+    return BDA_HALPHA_NOT_SET;
+}
 
-    int dvb_SubmitDVBSTuneRequest( access_t* p_access )
+static Polarisation dvb_parse_polarization (char pol)
+{
+    switch (pol)
     {
-        if( p_access->p_sys->p_bda_module )
-            return p_access->p_sys->p_bda_module->SubmitDVBSTuneRequest();
-        return VLC_EGENERIC;
-    };
+        case 'H': return BDA_POLARISATION_LINEAR_H;
+        case 'V': return BDA_POLARISATION_LINEAR_V;
+        case 'L': return BDA_POLARISATION_CIRCULAR_L;
+        case 'R': return BDA_POLARISATION_CIRCULAR_R;
+    }
+    return BDA_POLARISATION_NOT_SET;
+}
 
-    block_t *dvb_Pop( access_t* p_access )
+static SpectralInversion dvb_parse_inversion (int inversion)
+{
+    switch (inversion)
     {
-        if( p_access->p_sys->p_bda_module )
-            return p_access->p_sys->p_bda_module->Pop();
-        return NULL;
-    };
+        case  0: return BDA_SPECTRAL_INVERSION_NORMAL;
+        case  1: return BDA_SPECTRAL_INVERSION_INVERTED;
+        case -1: return BDA_SPECTRAL_INVERSION_AUTOMATIC;
+    }
+    /* should never happen */
+    return BDA_SPECTRAL_INVERSION_NOT_SET;
+}
+
+/****************************************************************************
+ * Interfaces for calls from C
+ ****************************************************************************/
+struct dvb_device
+{
+    BDAGraph *module;
+
+    /* DVB-S property cache */
+    uint32_t frequency;
+    uint32_t srate;
+    uint32_t fec;
+    char inversion;
+    char pol;
+    uint32_t lowf, highf, switchf;
 };
 
+dvb_device_t *dvb_open (vlc_object_t *obj, bool tune)
+{
+    if (!tune)
+        return NULL; /* not implemented (yet?) */
+
+    dvb_device_t *d = new dvb_device_t;
+
+    d->module = new BDAGraph (obj);
+    d->frequency = 0;
+    d->srate = 0;
+    d->fec = VLC_FEC_AUTO;
+    d->inversion = -1;
+    d->pol = 0;
+    d->lowf = d->highf = d->switchf = 0;
+    return d;
+}
+
+void dvb_close (dvb_device_t *d)
+{
+    delete d->module;
+    delete d;
+}
+
+ssize_t dvb_read (dvb_device_t *d, void *buf, size_t len)
+{
+    return d->module->Pop(buf, len);
+}
+
+int dvb_add_pid (dvb_device_t *, uint16_t)
+{
+    return 0;
+}
+
+void dvb_remove_pid (dvb_device_t *, uint16_t)
+{
+}
+
+const delsys_t *dvb_guess_system (dvb_device_t *d)
+{
+    return NULL;
+}
+
+float dvb_get_signal_strength (dvb_device_t *)
+{
+    return 0.;
+}
+
+float dvb_get_snr (dvb_device_t *)
+{
+    return 0.;
+}
+
+int dvb_set_inversion (dvb_device_t *d, int inversion)
+{
+    d->inversion = inversion;
+    if (d->frequency == 0)
+        return 0; /* not DVB-S */
+    return d->module->SetDVBS(d->frequency, d->srate, d->fec, d->inversion,
+                              d->pol, d->lowf, d->highf, d->switchf);
+}
+
+int dvb_tune (dvb_device_t *d)
+{
+    return d->module->SubmitTuneRequest ();
+}
+
+/* DVB-C */
+int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *mod,
+                  uint32_t srate, uint32_t fec)
+{
+    return d->module->SetDVBC (freq, mod, srate);
+}
+
+/* DVB-S */
+int dvb_set_dvbs (dvb_device_t *d, uint32_t freq, uint32_t srate, uint32_t fec)
+{
+    d->frequency = freq;
+    d->srate = srate;
+    d->fec = fec;
+    return d->module->SetDVBS(d->frequency, d->srate, d->fec, d->inversion,
+                              d->pol, d->lowf, d->highf, d->switchf);
+}
+
+int dvb_set_dvbs2 (dvb_device_t *d, uint32_t freq, const char *mod,
+                   uint32_t srate, uint32_t fec, int pilot, int rolloff)
+{
+    return VLC_EGENERIC;
+}
+
+int dvb_set_sec (dvb_device_t *d, uint32_t freq, char pol,
+                 uint32_t lowf, uint32_t highf, uint32_t switchf)
+{
+    d->frequency = freq;
+    d->pol = pol;
+    d->lowf = lowf;
+    d->highf = highf;
+    d->switchf = switchf;
+    return d->module->SetDVBS(d->frequency, d->srate, d->fec, d->inversion,
+                              d->pol, d->lowf, d->highf, d->switchf);
+}
+
+/* DVB-T */
+int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char *mod,
+                  uint32_t fec_hp, uint32_t fec_lp, uint32_t bandwidth,
+                  int transmission, uint32_t guard, int hierarchy)
+{
+    return d->module->SetDVBT(freq, fec_hp, fec_lp,
+                              bandwidth, transmission, guard, hierarchy);
+}
+
+/* ATSC */
+int dvb_set_atsc (dvb_device_t *d, uint32_t freq, const char *mod)
+{
+    return d->module->SetATSC(freq);
+}
+
+int dvb_set_cqam (dvb_device_t *d, uint32_t freq, const char *mod)
+{
+    return d->module->SetCQAM(freq);
+}
+
+
 /*****************************************************************************
 * BDAOutput
 *****************************************************************************/
-BDAOutput::BDAOutput( access_t *p_access ) :
+BDAOutput::BDAOutput( vlc_object_t *p_access ) :
     p_access(p_access), p_first(NULL), pp_next(&p_first)
 {
     vlc_mutex_init( &lock );
     vlc_cond_init( &wait );
 }
+
 BDAOutput::~BDAOutput()
 {
     Empty();
     vlc_mutex_destroy( &lock );
     vlc_cond_destroy( &wait );
 }
+
 void BDAOutput::Push( block_t *p_block )
 {
     vlc_mutex_locker l( &lock );
@@ -106,20 +276,33 @@ void BDAOutput::Push( block_t *p_block )
     block_ChainLastAppend( &pp_next, p_block );
     vlc_cond_signal( &wait );
 }
-block_t *BDAOutput::Pop()
+
+ssize_t BDAOutput::Pop(void *buf, size_t len)
 {
-    vlc_mutex_locker l( &lock );
+    block_t *block;
+    {
+        vlc_mutex_locker l( &lock );
 
-    if( !p_first )
-        vlc_cond_timedwait( &wait, &lock, mdate() + 250*1000 );
+        if( !p_first )
+            vlc_cond_timedwait( &wait, &lock, mdate() + 250*1000 );
 
-    block_t *p_ret = p_first;
+        block = p_first;
+        p_first = NULL;
+        pp_next = &p_first;
+    }
 
-    p_first = NULL;
-    pp_next = &p_first;
+    if(block == NULL)
+        return -1;
 
-    return p_ret;
+    if(len < block->i_buffer)
+        msg_Err(p_access, "buffer overflow!");
+    else
+        len = block->i_buffer;
+    vlc_memcpy(buf, block->p_buffer, len);
+    block_Release(block);
+    return len;
 }
+
 void BDAOutput::Empty()
 {
     vlc_mutex_locker l( &lock );
@@ -133,7 +316,7 @@ void BDAOutput::Empty()
 /*****************************************************************************
 * Constructor
 *****************************************************************************/
-BDAGraph::BDAGraph( access_t* p_this ):
+BDAGraph::BDAGraph( vlc_object_t *p_this ):
     p_access( p_this ),
     guid_network_type(GUID_NULL),
     l_tuner_used(-1),
@@ -164,10 +347,34 @@ BDAGraph::~BDAGraph()
     CoUninitialize();
 }
 
+
+int BDAGraph::SubmitTuneRequest(void)
+{
+    HRESULT hr;
+
+    /* Build and Run the Graph. If a Tuner device is in use the graph will
+     * fail to run. Repeated calls to build will check successive tuner
+     * devices */
+    do
+    {
+        hr = Build();
+        if( FAILED( hr ) )
+        {
+            msg_Warn( p_access, "SubmitTuneRequest: "
+                      "Cannot Build the Graph: hr=0x%8lx", hr );
+            return VLC_EGENERIC;
+        }
+        hr = Start();
+    }
+    while( hr != S_OK );
+
+    return VLC_SUCCESS;
+}
+
 /*****************************************************************************
-* Submit an Clear QAM Tune Request (US Cable Shit)
+* Set clear QAM (US cable)
 *****************************************************************************/
-int BDAGraph::SubmitCQAMTuneRequest()
+int BDAGraph::SetCQAM(long l_frequency)
 {
     HRESULT hr = S_OK;
     class localComPtr
@@ -184,18 +391,17 @@ int BDAGraph::SubmitCQAMTuneRequest()
                 p_cqam_locator->Release();
         }
     } l;
-    long l_minor_channel, l_physical_channel, l_frequency;
+    long l_minor_channel, l_physical_channel;
 
     l_physical_channel = var_GetInteger( p_access, "dvb-physical-channel" );
     l_minor_channel    = var_GetInteger( p_access, "dvb-minor-channel" );
-    l_frequency        = var_GetInteger( p_access, "dvb-frequency" );
 
     guid_network_type = CLSID_DigitalCableNetworkType;
     hr = CreateTuneRequest();
     if( FAILED( hr ) )
     {
         msg_Warn( p_access, "SubmitCQAMTuneRequest: "\
-            "Cannot create Tuning Space: hr=0x%8lx", hr );
+                 "Cannot create Tuning Space: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
 
@@ -204,7 +410,7 @@ int BDAGraph::SubmitCQAMTuneRequest()
     if( FAILED( hr ) )
     {
         msg_Warn( p_access, "SubmitCQAMTuneRequest: "\
-            "Cannot QI for IDigitalCableTuneRequest: hr=0x%8lx", hr );
+                  "Cannot QI for IDigitalCableTuneRequest: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
     hr = ::CoCreateInstance( CLSID_DigitalCableLocator, 0, CLSCTX_INPROC,
@@ -212,7 +418,7 @@ int BDAGraph::SubmitCQAMTuneRequest()
     if( FAILED( hr ) )
     {
         msg_Warn( p_access, "SubmitCQAMTuneRequest: "\
-            "Cannot create the CQAM locator: hr=0x%8lx", hr );
+                  "Cannot create the CQAM locator: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
 
@@ -226,7 +432,7 @@ int BDAGraph::SubmitCQAMTuneRequest()
     if( FAILED( hr ) )
     {
         msg_Warn( p_access, "SubmitCQAMTuneRequest: "\
-            "Cannot set tuning parameters: hr=0x%8lx", hr );
+                 "Cannot set tuning parameters: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
 
@@ -234,33 +440,17 @@ int BDAGraph::SubmitCQAMTuneRequest()
     if( FAILED( hr ) )
     {
         msg_Warn( p_access, "SubmitCQAMTuneRequest: "\
-            "Cannot put the locator: hr=0x%8lx", hr );
+                  "Cannot put the locator: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
 
-    /* Build and Run the Graph. If a Tuner device is in use the graph will
-     * fail to run. Repeated calls to build will check successive tuner
-     * devices */
-    do
-    {
-        hr = Build();
-        if( FAILED( hr ) )
-        {
-            msg_Warn( p_access, "SubmitCQAMTuneRequest: "\
-                "Cannot Build the Graph: hr=0x%8lx", hr );
-            return VLC_EGENERIC;
-        }
-        hr = Start();
-    }
-    while( hr != S_OK );
-
     return VLC_SUCCESS;
 }
 
 /*****************************************************************************
-* Submit an ATSC Tune Request
+* Set ATSC
 *****************************************************************************/
-int BDAGraph::SubmitATSCTuneRequest()
+int BDAGraph::SetATSC(long l_frequency)
 {
     HRESULT hr = S_OK;
     class localComPtr
@@ -278,12 +468,10 @@ int BDAGraph::SubmitATSCTuneRequest()
         }
     } l;
     long l_major_channel, l_minor_channel, l_physical_channel;
-    long l_frequency;
 
     l_major_channel     = var_GetInteger( p_access, "dvb-major-channel" );
     l_minor_channel     = var_GetInteger( p_access, "dvb-minor-channel" );
     l_physical_channel  = var_GetInteger( p_access, "dvb-physical-channel" );
-    l_frequency         = var_GetInteger( p_access, "dvb-frequency" );
 
     guid_network_type = CLSID_ATSCNetworkProvider;
     hr = CreateTuneRequest();
@@ -334,30 +522,14 @@ int BDAGraph::SubmitATSCTuneRequest()
             "Cannot put the locator: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
-
-    /* Build and Run the Graph. If a Tuner device is in use the graph will
-     * fail to run. Repeated calls to build will check successive tuner
-     * devices */
-    do
-    {
-        hr = Build();
-        if( FAILED( hr ) )
-        {
-            msg_Warn( p_access, "SubmitATSCTuneRequest: "\
-                "Cannot Build the Graph: hr=0x%8lx", hr );
-            return VLC_EGENERIC;
-        }
-        hr = Start();
-    }
-    while( hr != S_OK );
-
     return VLC_SUCCESS;
 }
 
 /*****************************************************************************
-* Submit a DVB-T Tune Request
+* Set DVB-T
 ******************************************************************************/
-int BDAGraph::SubmitDVBTTuneRequest()
+int BDAGraph::SetDVBT(long l_frequency, uint32_t fec_hp, uint32_t fec_lp,
+    long l_bandwidth, int transmission, uint32_t guard, int hierarchy)
 {
     HRESULT hr = S_OK;
     class localComPtr
@@ -378,88 +550,12 @@ int BDAGraph::SubmitDVBTTuneRequest()
                 p_dvb_tuning_space->Release();
         }
     } l;
-    long l_frequency, l_bandwidth, l_hp_fec, l_lp_fec, l_guard;
-    long l_transmission, l_hierarchy;
-    BinaryConvolutionCodeRate i_hp_fec, i_lp_fec;
-    GuardInterval             i_guard;
-    TransmissionMode          i_transmission;
-    HierarchyAlpha            i_hierarchy;
-
-    l_frequency    = var_GetInteger( p_access, "dvb-frequency" ) / 1000;
-    l_bandwidth    = var_GetInteger( p_access, "dvb-bandwidth" );
-    l_hp_fec       = var_GetInteger( p_access, "dvb-code-rate-hp" );
-    l_lp_fec       = var_GetInteger( p_access, "dvb-code-rate-lp" );
-    l_guard        = var_GetInteger( p_access, "dvb-guard" );
-    l_transmission = var_GetInteger( p_access, "dvb-transmission" );
-    l_hierarchy    = var_GetInteger( p_access, "dvb-hierarchy" );
-
-    switch( l_hp_fec )
-    {
-    case 1:
-        i_hp_fec = BDA_BCC_RATE_1_2; break;
-    case 2:
-        i_hp_fec = BDA_BCC_RATE_2_3; break;
-    case 3:
-        i_hp_fec = BDA_BCC_RATE_3_4; break;
-    case 4:
-        i_hp_fec = BDA_BCC_RATE_5_6; break;
-    case 5:
-        i_hp_fec = BDA_BCC_RATE_7_8;break;
-    default:
-        i_hp_fec = BDA_BCC_RATE_NOT_SET;
-    }
-
-    switch( l_lp_fec )
-    {
-    case 1:
-        i_lp_fec = BDA_BCC_RATE_1_2; break;
-    case 2:
-        i_lp_fec = BDA_BCC_RATE_2_3; break;
-    case 3:
-        i_lp_fec = BDA_BCC_RATE_3_4; break;
-    case 4:
-        i_lp_fec = BDA_BCC_RATE_5_6; break;
-    case 5:
-        i_lp_fec = BDA_BCC_RATE_7_8; break;
-    default:
-        i_lp_fec = BDA_BCC_RATE_NOT_SET;
-    }
-
-    switch( l_guard )
-    {
-    case 32:
-        i_guard = BDA_GUARD_1_32; break;
-    case 16:
-        i_guard = BDA_GUARD_1_16; break;
-    case 8:
-        i_guard = BDA_GUARD_1_8; break;
-    case 4:
-        i_guard = BDA_GUARD_1_4; break;
-    default:
-        i_guard = BDA_GUARD_NOT_SET;
-    }
-
-    switch( l_transmission )
-    {
-    case 2:
-        i_transmission = BDA_XMIT_MODE_2K; break;
-    case 8:
-        i_transmission = BDA_XMIT_MODE_8K; break;
-    default:
-        i_transmission = BDA_XMIT_MODE_NOT_SET;
-    }
-
-    switch( l_hierarchy )
-    {
-    case 1:
-        i_hierarchy = BDA_HALPHA_1; break;
-    case 2:
-        i_hierarchy = BDA_HALPHA_2; break;
-    case 4:
-        i_hierarchy = BDA_HALPHA_4; break;
-    default:
-        i_hierarchy = BDA_HALPHA_NOT_SET;
-    }
+
+    BinaryConvolutionCodeRate i_hp_fec = dvb_parse_fec(fec_hp);
+    BinaryConvolutionCodeRate i_lp_fec = dvb_parse_fec(fec_lp);
+    GuardInterval i_guard = dvb_parse_guard(guard);
+    TransmissionMode i_transmission = dvb_parse_transmission(transmission);
+    HierarchyAlpha i_hierarchy = dvb_parse_hierarchy(hierarchy);
 
     guid_network_type = CLSID_DVBTNetworkProvider;
     hr = CreateTuneRequest();
@@ -531,29 +627,13 @@ int BDAGraph::SubmitDVBTTuneRequest()
         return VLC_EGENERIC;
     }
 
-    /* Build and Run the Graph. If a Tuner device is in use the graph will
-     * fail to run. Repeated calls to build will check successive tuner
-     * devices */
-    do
-    {
-        hr = Build();
-        if( FAILED( hr ) )
-        {
-            msg_Warn( p_access, "SubmitDVBTTuneRequest: "\
-                "Cannot Build the Graph: hr=0x%8lx", hr );
-            return VLC_EGENERIC;
-        }
-        hr = Start();
-    }
-    while( hr != S_OK );
-
     return VLC_SUCCESS;
 }
 
 /*****************************************************************************
-* Submit a DVB-C Tune Request
+* Set DVB-C
 ******************************************************************************/
-int BDAGraph::SubmitDVBCTuneRequest()
+int BDAGraph::SetDVBC(long l_frequency, const char *mod, long l_symbolrate)
 {
     HRESULT hr = S_OK;
 
@@ -577,29 +657,7 @@ int BDAGraph::SubmitDVBCTuneRequest()
         }
     } l;
 
-    long l_frequency, l_symbolrate;
-    int  i_qam;
-    ModulationType i_qam_mod;
-
-    l_frequency  = var_GetInteger( p_access, "dvb-frequency" ) / 1000;
-    l_symbolrate = var_GetInteger( p_access, "dvb-srate" );
-    i_qam        = var_GetInteger( p_access, "dvb-modulation" );
-
-    switch( i_qam )
-    {
-    case 16:
-        i_qam_mod = BDA_MOD_16QAM; break;
-    case 32:
-        i_qam_mod = BDA_MOD_32QAM; break;
-    case 64:
-        i_qam_mod = BDA_MOD_64QAM; break;
-    case 128:
-        i_qam_mod = BDA_MOD_128QAM; break;
-    case 256:
-        i_qam_mod = BDA_MOD_256QAM; break;
-    default:
-        i_qam_mod = BDA_MOD_NOT_SET;
-    }
+    ModulationType i_qam_mod = dvb_parse_modulation(mod);
 
     guid_network_type = CLSID_DVBCNetworkProvider;
     hr = CreateTuneRequest();
@@ -664,29 +722,15 @@ int BDAGraph::SubmitDVBCTuneRequest()
         return VLC_EGENERIC;
     }
 
-    /* Build and Run the Graph. If a Tuner device is in use the graph will
-     * fail to run. Repeated calls to build will check successive tuner
-     * devices */
-    do
-    {
-        hr = Build();
-        if( FAILED( hr ) )
-        {
-            msg_Warn( p_access, "SubmitDVBCTuneRequest: "\
-                "Cannot Build the Graph: hr=0x%8lx", hr );
-            return VLC_EGENERIC;
-        }
-        hr = Start();
-    }
-    while( hr != S_OK );
-
     return VLC_SUCCESS;
 }
 
 /*****************************************************************************
-* Submit a DVB-S Tune Request
+* Set DVB-S
 ******************************************************************************/
-int BDAGraph::SubmitDVBSTuneRequest()
+int BDAGraph::SetDVBS(long l_frequency, long l_symbolrate, uint32_t fec,
+                      int inversion, char pol,
+                      long l_lnb_lof1, long l_lnb_lof2, long l_lnb_slof)
 {
     HRESULT hr = S_OK;
 
@@ -719,96 +763,25 @@ int BDAGraph::SubmitDVBSTuneRequest()
             free( psz_polarisation );
         }
     } l;
-    long l_frequency, l_symbolrate, l_azimuth, l_elevation, l_longitude;
-    long l_lnb_lof1, l_lnb_lof2, l_lnb_slof, l_inversion, l_network_id;
-    long l_hp_fec;
-    int  i_mod;
-    Polarisation i_polar;
-    SpectralInversion i_inversion;
+    long l_azimuth, l_elevation, l_longitude;
+    long l_network_id;
     VARIANT_BOOL b_west;
-    BinaryConvolutionCodeRate i_hp_fec;
-    ModulationType i_mod_typ;
 
-    l_frequency        = var_GetInteger( p_access, "dvb-frequency" );
-    l_symbolrate       = var_GetInteger( p_access, "dvb-srate" );
+    BinaryConvolutionCodeRate i_hp_fec = dvb_parse_fec( fec );
+    Polarisation i_polar = dvb_parse_polarization( pol );
+    SpectralInversion i_inversion = dvb_parse_inversion( inversion );
+
     l_azimuth          = var_GetInteger( p_access, "dvb-azimuth" );
     l_elevation        = var_GetInteger( p_access, "dvb-elevation" );
     l_longitude        = var_GetInteger( p_access, "dvb-longitude" );
-    l_lnb_lof1         = var_GetInteger( p_access, "dvb-lnb-lof1" );
-    l_lnb_lof2         = var_GetInteger( p_access, "dvb-lnb-lof2" );
-    l_lnb_slof         = var_GetInteger( p_access, "dvb-lnb-slof" );
-    i_mod              = var_GetInteger( p_access, "dvb-modulation" );
-    l_hp_fec           = var_GetInteger( p_access, "dvb-code-rate-hp" );
-    l_inversion        = var_GetInteger( p_access, "dvb-inversion" );
     l_network_id       = var_GetInteger( p_access, "dvb-network-id" );
 
     l.psz_input_range  = var_GetNonEmptyString( p_access, "dvb-range" );
-    l.psz_polarisation = var_GetNonEmptyString( p_access, "dvb-polarisation" );
+    if( asprintf( &l.psz_polarisation, "%c", pol ) == -1 )
+        abort();
 
     b_west = ( l_longitude < 0 );
 
-    i_polar = BDA_POLARISATION_NOT_SET;
-    if( l.psz_polarisation != NULL )
-    {
-        switch( toupper( l.psz_polarisation[0] ) )
-        {
-        case 'H':
-            i_polar = BDA_POLARISATION_LINEAR_H;
-            break;
-        case 'V':
-            i_polar = BDA_POLARISATION_LINEAR_V;
-            break;
-        case 'L':
-            i_polar = BDA_POLARISATION_CIRCULAR_L;
-            break;
-        case 'R':
-            i_polar = BDA_POLARISATION_CIRCULAR_R;
-            break;
-        }
-    }
-
-    switch( l_inversion )
-    {
-    case 0:
-        i_inversion = BDA_SPECTRAL_INVERSION_NORMAL; break;
-    case 1:
-        i_inversion = BDA_SPECTRAL_INVERSION_INVERTED; break;
-    case 2:
-        i_inversion = BDA_SPECTRAL_INVERSION_AUTOMATIC; break;
-    default:
-        i_inversion = BDA_SPECTRAL_INVERSION_NOT_SET;
-    }
-
-    switch( i_mod )
-    {
-    case 16:
-        i_mod_typ = BDA_MOD_16QAM; break;
-    case 128:
-        i_mod_typ = BDA_MOD_128QAM; break;
-    case 256:
-        i_mod_typ = BDA_MOD_256QAM; break;
-    case 10004:
-        i_mod_typ = BDA_MOD_QPSK; break;
-    default:
-        i_mod_typ = BDA_MOD_NOT_SET;
-    }
-
-    switch( l_hp_fec )
-    {
-    case 1:
-        i_hp_fec = BDA_BCC_RATE_1_2; break;
-    case 2:
-        i_hp_fec = BDA_BCC_RATE_2_3; break;
-    case 3:
-        i_hp_fec = BDA_BCC_RATE_3_4; break;
-    case 4:
-        i_hp_fec = BDA_BCC_RATE_5_6; break;
-    case 5:
-        i_hp_fec = BDA_BCC_RATE_7_8; break;
-    default:
-        i_hp_fec = BDA_BCC_RATE_NOT_SET;
-    }
-
     l.i_range_len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
         l.psz_input_range, -1, l.pwsz_input_range, 0 );
     if( l.i_range_len > 0 )
@@ -879,8 +852,8 @@ int BDAGraph::SubmitDVBSTuneRequest()
         hr = l.p_dvbs_locator->put_SymbolRate( l_symbolrate );
     if( SUCCEEDED( hr ) && i_polar != BDA_POLARISATION_NOT_SET )
         hr = l.p_dvbs_locator->put_SignalPolarisation( i_polar );
-    if( SUCCEEDED( hr ) && i_mod_typ != BDA_MOD_NOT_SET )
-        hr = l.p_dvbs_locator->put_Modulation( i_mod_typ );
+    if( SUCCEEDED( hr ) )
+        hr = l.p_dvbs_locator->put_Modulation( BDA_MOD_QPSK );
     if( SUCCEEDED( hr ) && i_hp_fec != BDA_BCC_RATE_NOT_SET )
         hr = l.p_dvbs_locator->put_InnerFECRate( i_hp_fec );
 
@@ -907,22 +880,6 @@ int BDAGraph::SubmitDVBSTuneRequest()
         return VLC_EGENERIC;
     }
 
-    /* Build and Run the Graph. If a Tuner device is in use the graph will
-     * fail to run. Repeated calls to build will check successive tuner
-     * devices */
-    do
-    {
-        hr = Build();
-        if( FAILED( hr ) )
-        {
-            msg_Warn( p_access, "SubmitDVBSTuneRequest: "\
-                "Cannot Build the Graph: hr=0x%8lx", hr );
-            return VLC_EGENERIC;
-        }
-        hr = Start();
-    }
-    while( hr != S_OK );
-
     return VLC_SUCCESS;
 }
 
@@ -1894,9 +1851,9 @@ HRESULT BDAGraph::Start()
 /*****************************************************************************
 * Pop the stream of data
 *****************************************************************************/
-block_t *BDAGraph::Pop()
+ssize_t BDAGraph::Pop(void *buf, size_t len)
 {
-    return output.Pop();
+    return output.Pop(buf, len);
 }
 
 /******************************************************************************
similarity index 86%
rename from modules/access/bda/bdagraph.h
rename to modules/access/dtv/bdagraph.hpp
index 3b1b50df09b71856f2d54b356a7350679302be2c..d51baed53ae1d531c8c7d7faa07ecf16b01bbb55 100644 (file)
@@ -24,8 +24,6 @@
  * Preamble
  *****************************************************************************/
 
-#include "bda.h"
-
 using namespace std;
 #ifndef _MSC_VER
 #   include <wtypes.h>
@@ -50,23 +48,23 @@ using namespace std;
 
 #include <dshow.h>
 #include <comcat.h>
-#include "bdadefs.h"
+#include "dtv/bdadefs.h"
 
 class BDAOutput
 {
 public:
-    BDAOutput( access_t * );
+    BDAOutput( vlc_object_t * );
     ~BDAOutput();
 
     void    Push( block_t * );
-    block_t *Pop();
+    ssize_t Pop(void *, size_t);
     void    Empty();
 
 private:
-    access_t    *p_access;
-    vlc_mutex_t lock;
-    vlc_cond_t  wait;
-    block_t     *p_first;
+    vlc_object_t *p_access;
+    vlc_mutex_t   lock;
+    vlc_cond_t    wait;
+    block_t      *p_first;
     block_t     **pp_next;
 };
 
@@ -74,18 +72,20 @@ private:
 class BDAGraph : public ISampleGrabberCB
 {
 public:
-    BDAGraph( access_t* p_access );
+    BDAGraph( vlc_object_t * );
     virtual ~BDAGraph();
 
     /* */
-    int SubmitCQAMTuneRequest();
-    int SubmitATSCTuneRequest();
-    int SubmitDVBTTuneRequest();
-    int SubmitDVBCTuneRequest();
-    int SubmitDVBSTuneRequest();
+    int SubmitTuneRequest(void);
+
+    int SetCQAM(long);
+    int SetATSC(long);
+    int SetDVBT(long, uint32_t, uint32_t, long, int, uint32_t, int);
+    int SetDVBC(long, const char *, long);
+    int SetDVBS(long, long, uint32_t, int, char, long, long, long);
 
     /* */
-    block_t *Pop();
+    ssize_t Pop(void *, size_t);
 
 private:
     /* ISampleGrabberCB methods */
@@ -97,7 +97,7 @@ private:
     STDMETHODIMP SampleCB( double d_time, IMediaSample* p_sample );
     STDMETHODIMP BufferCB( double d_time, BYTE* p_buffer, long l_buffer_len );
 
-    access_t* p_access;
+    vlc_object_t *p_access;
     CLSID     guid_network_type;
     long      l_tuner_used;        /* Index of the Tuning Device */
     /* registration number for the RunningObjectTable */