]> git.sesse.net Git - vlc/blobdiff - modules/access/bda/bdagraph.cpp
Swedish translation update by Daniel Nylander
[vlc] / modules / access / bda / bdagraph.cpp
index b45d39c16c44b3bbbc65f27f9e16127f40a97b69..c60be0a04981a6843b20264b135325b315c55e46 100644 (file)
@@ -24,6 +24,7 @@
  * Preamble
  *****************************************************************************/
 #include "bdagraph.h"
+#include <ctype.h>
 
 /****************************************************************************
  * Interfaces for calls from C
@@ -37,38 +38,51 @@ extern "C" {
 
     void dvb_deleteBDAGraph( access_t* p_access )
     {
-        delete p_access->p_sys->p_bda_module;
+        if( p_access->p_sys->p_bda_module )
+            delete p_access->p_sys->p_bda_module;
     };
 
     int dvb_SubmitATSCTuneRequest( access_t* p_access )
     {
-        return p_access->p_sys->p_bda_module->SubmitATSCTuneRequest();
+        if( p_access->p_sys->p_bda_module )
+            return p_access->p_sys->p_bda_module->SubmitATSCTuneRequest();
+        return VLC_EGENERIC;
     };
 
     int dvb_SubmitDVBTTuneRequest( access_t* p_access )
     {
-        return p_access->p_sys->p_bda_module->SubmitDVBTTuneRequest();
+        if( p_access->p_sys->p_bda_module )
+            return p_access->p_sys->p_bda_module->SubmitDVBTTuneRequest();
+        return VLC_EGENERIC;
     };
 
     int dvb_SubmitDVBCTuneRequest( access_t* p_access )
     {
-        return p_access->p_sys->p_bda_module->SubmitDVBCTuneRequest();
-    };    
+        if( p_access->p_sys->p_bda_module )
+            return p_access->p_sys->p_bda_module->SubmitDVBCTuneRequest();
+        return VLC_EGENERIC;
+    };
 
     int dvb_SubmitDVBSTuneRequest( access_t* p_access )
     {
-        return p_access->p_sys->p_bda_module->SubmitDVBSTuneRequest();
+        if( p_access->p_sys->p_bda_module )
+            return p_access->p_sys->p_bda_module->SubmitDVBSTuneRequest();
+        return VLC_EGENERIC;
     };
 
     long dvb_GetBufferSize( access_t* p_access )
     {
-        return p_access->p_sys->p_bda_module->GetBufferSize();
+        if( p_access->p_sys->p_bda_module )
+            return p_access->p_sys->p_bda_module->GetBufferSize();
+        return -1;
     };
 
     long dvb_ReadBuffer( access_t* p_access, long* l_buffer_len, BYTE* p_buff )
     {
-        return p_access->p_sys->p_bda_module->ReadBuffer( l_buffer_len, 
-            p_buff );
+        if( p_access->p_sys->p_bda_module )
+            return p_access->p_sys->p_bda_module->ReadBuffer( l_buffer_len,
+                p_buff );
+        return -1;
     };
 };
 
@@ -222,11 +236,70 @@ int BDAGraph::SubmitDVBTTuneRequest()
                 p_dvbt_locator->Release();
         }
     } l;
-    long l_frequency, l_bandwidth;
-
-    l_frequency = l_bandwidth = -1;
+    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 = l_bandwidth = l_hp_fec = l_lp_fec = l_guard = -1;
+    l_transmission = l_hierarchy = -1;
     l_frequency = var_GetInteger( p_access, "dvb-frequency" );
     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" );
+
+    i_hp_fec = BDA_BCC_RATE_NOT_SET;
+    if( l_hp_fec == 1 )
+        i_hp_fec = BDA_BCC_RATE_1_2;
+    if( l_hp_fec == 2 )
+        i_hp_fec = BDA_BCC_RATE_2_3;
+    if( l_hp_fec == 3 )
+        i_hp_fec = BDA_BCC_RATE_3_4;
+    if( l_hp_fec == 4 )
+        i_hp_fec = BDA_BCC_RATE_5_6;
+    if( l_hp_fec == 5 )
+        i_hp_fec = BDA_BCC_RATE_7_8;
+
+    i_lp_fec = BDA_BCC_RATE_NOT_SET;
+    if( l_lp_fec == 1 )
+        i_lp_fec = BDA_BCC_RATE_1_2;
+    if( l_lp_fec == 2 )
+        i_lp_fec = BDA_BCC_RATE_2_3;
+    if( l_lp_fec == 3 )
+        i_lp_fec = BDA_BCC_RATE_3_4;
+    if( l_lp_fec == 4 )
+        i_lp_fec = BDA_BCC_RATE_5_6;
+    if( l_lp_fec == 5 )
+        i_lp_fec = BDA_BCC_RATE_7_8;
+
+    i_guard = BDA_GUARD_NOT_SET;
+    if( l_guard == 32 )
+        i_guard = BDA_GUARD_1_32;
+    if( l_guard == 16 )
+        i_guard = BDA_GUARD_1_16;
+    if( l_guard == 8 )
+        i_guard = BDA_GUARD_1_8;
+    if( l_guard == 4 )
+        i_guard = BDA_GUARD_1_4;
+
+    i_transmission = BDA_XMIT_MODE_NOT_SET;
+    if( l_transmission == 2 )
+        i_transmission = BDA_XMIT_MODE_2K;
+    if( l_transmission == 8 )
+        i_transmission = BDA_XMIT_MODE_8K;
+
+    i_hierarchy = BDA_HALPHA_NOT_SET;
+    if( l_hierarchy == 1 )
+        i_hierarchy = BDA_HALPHA_1;
+    if( l_hierarchy == 2 )
+        i_hierarchy = BDA_HALPHA_2;
+    if( l_hierarchy == 4 )
+        i_hierarchy = BDA_HALPHA_4;
 
     guid_network_type = CLSID_DVBTNetworkProvider;
     hr = CreateTuneRequest();
@@ -263,6 +336,16 @@ int BDAGraph::SubmitDVBTTuneRequest()
         hr = l.p_dvbt_locator->put_CarrierFrequency( l_frequency );
     if( SUCCEEDED( hr ) && l_bandwidth > 0 )
         hr = l.p_dvbt_locator->put_Bandwidth( l_bandwidth );
+    if( SUCCEEDED( hr ) && i_hp_fec != BDA_BCC_RATE_NOT_SET )
+        hr = l.p_dvbt_locator->put_InnerFECRate( i_hp_fec );
+    if( SUCCEEDED( hr ) && i_lp_fec != BDA_BCC_RATE_NOT_SET )
+        hr = l.p_dvbt_locator->put_LPInnerFECRate( i_lp_fec );
+    if( SUCCEEDED( hr ) && i_guard != BDA_GUARD_NOT_SET )
+        hr = l.p_dvbt_locator->put_Guard( i_guard );
+    if( SUCCEEDED( hr ) && i_transmission != BDA_XMIT_MODE_NOT_SET )
+        hr = l.p_dvbt_locator->put_Mode( i_transmission );
+    if( SUCCEEDED( hr ) && i_hierarchy != BDA_HALPHA_NOT_SET )
+        hr = l.p_dvbt_locator->put_HAlpha( i_hierarchy );
     if( FAILED( hr ) )
     {
         msg_Warn( p_access, "SubmitDVBTTuneRequest: "\
@@ -422,9 +505,13 @@ int BDAGraph::SubmitDVBSTuneRequest()
         public:
         IDVBTuneRequest* p_dvbs_tune_request;
         IDVBSLocator* p_dvbs_locator;
-        localComPtr(): p_dvbs_tune_request(NULL), p_dvbs_locator(NULL) {};
+        IDVBSTuningSpace* p_dvbs_tuning_space;
+        localComPtr(): p_dvbs_tune_request(NULL), p_dvbs_locator(NULL),
+            p_dvbs_tuning_space(NULL) {};
         ~localComPtr()
         {
+            if( p_dvbs_tuning_space )
+                p_dvbs_tuning_space->Release();
             if( p_dvbs_tune_request )
                 p_dvbs_tune_request->Release();
             if( p_dvbs_locator )
@@ -432,35 +519,59 @@ int BDAGraph::SubmitDVBSTuneRequest()
         }
     } 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;
     char* psz_polarisation;
     Polarisation i_polar;
+    SpectralInversion i_inversion;
     VARIANT_BOOL b_west;
 
     l_frequency = l_symbolrate = l_azimuth = l_elevation = l_longitude = -1;
+    l_lnb_lof1 = l_lnb_lof2 = l_lnb_slof = l_inversion = l_network_id = -1;
     l_frequency = var_GetInteger( p_access, "dvb-frequency" );
     l_symbolrate = var_GetInteger( p_access, "dvb-srate" );
     l_azimuth = var_GetInteger( p_access, "dvb-azimuth" );
     l_elevation = var_GetInteger( p_access, "dvb-elevation" );
     l_longitude = var_GetInteger( p_access, "dvb-longitude" );
-    psz_polarisation = var_GetString( p_access, "dvb-polarisation" );
+    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" );
+    psz_polarisation = var_GetNonEmptyString( p_access, "dvb-polarisation" );
+    l_inversion = var_GetInteger( p_access, "dvb-inversion" );
+    l_network_id = var_GetInteger( p_access, "dvb-network_id" );
 
     b_west = ( l_longitude < 0 ) ? TRUE : FALSE;
 
     i_polar = BDA_POLARISATION_NOT_SET;
-    if( *psz_polarisation == 'H' || *psz_polarisation == 'h' )
-        i_polar = BDA_POLARISATION_LINEAR_H;
-    if( *psz_polarisation == 'V' || *psz_polarisation == 'v' )
-        i_polar = BDA_POLARISATION_LINEAR_V;
-    if( *psz_polarisation == 'L' || *psz_polarisation == 'l' )
-        i_polar = BDA_POLARISATION_CIRCULAR_L;
-    if( *psz_polarisation == 'R' || *psz_polarisation == 'r' )
-        i_polar = BDA_POLARISATION_CIRCULAR_R;
+    if( psz_polarisation != NULL )
+        switch( toupper( 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;
+        }
+
+    i_inversion = BDA_SPECTRAL_INVERSION_NOT_SET;
+    if( l_inversion == 0 )
+        i_inversion = BDA_SPECTRAL_INVERSION_NORMAL;
+    if( l_inversion == 1 )
+        i_inversion = BDA_SPECTRAL_INVERSION_INVERTED;
+    if( l_inversion == 2 )
+        i_inversion = BDA_SPECTRAL_INVERSION_AUTOMATIC;
 
     guid_network_type = CLSID_DVBSNetworkProvider;
     hr = CreateTuneRequest();
     if( FAILED( hr ) )
     {
-        msg_Warn( p_access, "SubmitDVBCTuneRequest: "\
+        msg_Warn( p_access, "SubmitDVBSTuneRequest: "\
             "Cannot create Tune Request: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
@@ -469,7 +580,7 @@ int BDAGraph::SubmitDVBSTuneRequest()
         (void**)&l.p_dvbs_tune_request );
     if( FAILED( hr ) )
     {
-        msg_Warn( p_access, "SubmitDVBCTuneRequest: "\
+        msg_Warn( p_access, "SubmitDVBSTuneRequest: "\
             "Cannot QI for IDVBTuneRequest: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
@@ -481,11 +592,20 @@ int BDAGraph::SubmitDVBSTuneRequest()
         IID_IDVBSLocator, (void**)&l.p_dvbs_locator );
     if( FAILED( hr ) )
     {
-        msg_Warn( p_access, "SubmitDVBCTuneRequest: "\
+        msg_Warn( p_access, "SubmitDVBSTuneRequest: "\
             "Cannot create the DVBS Locator: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
 
+    hr = p_tuning_space->QueryInterface( IID_IDVBSTuningSpace,
+        (void**)&l.p_dvbs_tuning_space );
+    if( FAILED( hr ) )
+    {
+        msg_Warn( p_access, "SubmitDVBSTuneRequest: "\
+            "Cannot QI for IDVBSTuningSpace: hr=0x%8lx", hr );
+        return VLC_EGENERIC;
+    }
+
     hr = S_OK;
     if( l_frequency > 0 )
         hr = l.p_dvbs_locator->put_CarrierFrequency( l_frequency );
@@ -501,9 +621,19 @@ int BDAGraph::SubmitDVBSTuneRequest()
         hr = l.p_dvbs_locator->put_WestPosition( b_west );
     if( SUCCEEDED( hr ) && i_polar != BDA_POLARISATION_NOT_SET )
         hr = l.p_dvbs_locator->put_SignalPolarisation( i_polar );
+    if( SUCCEEDED( hr ) && l_lnb_lof1 > 0 )
+        hr = l.p_dvbs_tuning_space->put_LowOscillator( l_lnb_lof1 );
+    if( SUCCEEDED( hr ) && l_lnb_lof2 > 0 )
+        hr = l.p_dvbs_tuning_space->put_HighOscillator( l_lnb_lof2 );
+    if( SUCCEEDED( hr ) && l_lnb_slof > 0 )
+        hr = l.p_dvbs_tuning_space->put_LNBSwitch( l_lnb_slof );
+    if( SUCCEEDED( hr ) && i_inversion != BDA_SPECTRAL_INVERSION_NOT_SET )
+        hr = l.p_dvbs_tuning_space->put_SpectralInversion( i_inversion );
+    if( SUCCEEDED( hr ) && l_network_id > 0 )
+        hr = l.p_dvbs_tuning_space->put_NetworkID( l_network_id );
     if( FAILED( hr ) )
     {
-        msg_Warn( p_access, "SubmitDVBCTuneRequest: "\
+        msg_Warn( p_access, "SubmitDVBSTuneRequest: "\
             "Cannot set tuning parameters on Locator: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
@@ -511,7 +641,7 @@ int BDAGraph::SubmitDVBSTuneRequest()
     hr = p_tune_request->put_Locator( l.p_dvbs_locator );
     if( FAILED( hr ) )
     {
-        msg_Warn( p_access, "SubmitDVBCTuneRequest: "\
+        msg_Warn( p_access, "SubmitDVBSTuneRequest: "\
             "Cannot put the locator: hr=0x%8lx", hr );
         return VLC_EGENERIC;
     }
@@ -1149,6 +1279,7 @@ HRESULT BDAGraph::Start()
         return hr;
 
     /* The Graph is not running so stop it and return an error */
+    msg_Warn( p_access, "Start: Graph not started: %d", i_state );
     hr = p_media_control->Stop();
     if( FAILED( hr ) )
     {
@@ -1297,7 +1428,7 @@ HRESULT BDAGraph::Destroy()
         p_media_control->Release();
         p_media_control = NULL;
     }
-    if( p_scanning_tuner )
+    if( p_filter_graph )
     {
         p_filter_graph->Release();
         p_filter_graph = NULL;