[dvblast-devel] DVB-T2 PLP support

4pr at legis.krsn.ru 4pr at legis.krsn.ru
Wed Feb 12 07:39:04 CET 2014


Hi,

Using code on below link as a reference, I just completed a patch for 
support DVB-T2 with ability to switch PLP ID. 

Just finished testing it. Here, in Russia, Krasnoyarsk, it's working as 
expected with broadcasting multiplex RTRS-1.

I would like to suggest it for developers review and possible inclusion.

Link: 
https://mailman.videolan.org/pipermail/dvblast-devel/2012-April/001002.html

Patch:

diff --git a/dvb.c b/dvb.c
index 6873da4..1191ad9 100644
--- a/dvb.c
+++ b/dvb.c
@@ -930,6 +930,26 @@ static struct dtv_properties dvbt_cmdseq = {
     .props = dvbt_cmdargs
 };

+static struct dtv_property dvbt2_cmdargs[] = {
+    { .cmd = DTV_DELIVERY_SYSTEM, .u.data = SYS_DVBT2 },
+    { .cmd = DTV_FREQUENCY,       .u.data = 0 },
+    { .cmd = DTV_MODULATION,      .u.data = QAM_AUTO },
+    { .cmd = DTV_INVERSION,       .u.data = INVERSION_AUTO },
+    { .cmd = DTV_BANDWIDTH_HZ,    .u.data = 8000000 },
+    { .cmd = DTV_CODE_RATE_HP,    .u.data = FEC_AUTO },
+    { .cmd = DTV_CODE_RATE_LP,    .u.data = FEC_AUTO },
+    { .cmd = DTV_GUARD_INTERVAL,  .u.data = GUARD_INTERVAL_AUTO },
+    { .cmd = DTV_TRANSMISSION_MODE,.u.data = TRANSMISSION_MODE_AUTO },
+    { .cmd = DTV_HIERARCHY,       .u.data = HIERARCHY_AUTO },
+    { .cmd = DTV_STREAM_ID,      .u.data = 0 },
+    { .cmd = DTV_TUNE },
+};
+
+static struct dtv_properties dvbt2_cmdseq = {
+    .num = sizeof(dvbt2_cmdargs)/sizeof(struct dtv_property),
+    .props = dvbt2_cmdargs
+};
+
 /* ATSC + DVB-C annex B */
 static struct dtv_property atsc_cmdargs[] = {
     { .cmd = DTV_DELIVERY_SYSTEM, .u.data = SYS_ATSC },
@@ -957,6 +977,7 @@ static struct dtv_properties atsc_cmdseq = {
 #define ROLLOFF 8
 #define MIS 9
 #define HIERARCHY 9
+#define PLP_ID 10

 struct dtv_property pclear[] = {
     { .cmd = DTV_CLEAR },
@@ -972,6 +993,8 @@ FrontendGuessSystem( fe_delivery_system_t *p_systems, 
int i_systems )
 {
     if ( psz_delsys != NULL )
     {
+       if ( !strcasecmp( psz_delsys, "DVBT2" ) )
+           return SYS_DVBT2;
         if ( !strcasecmp( psz_delsys, "DVBS" ) )
             return SYS_DVBS;
         if ( !strcasecmp( psz_delsys, "DVBS2" ) )
@@ -1000,6 +1023,10 @@ FrontendGuessSystem( fe_delivery_system_t 
*p_systems, int i_systems )
     {
         switch ( p_systems[i] )
         {
+           case SYS_DVBT2:
+               if ( i_frequency > 50000000 && (dvb_plp_id) )
+                   return SYS_DVBT2;
+               break;
             case SYS_DVBS:
                 if ( i_frequency < 50000000 )
                     return SYS_DVBS;
@@ -1018,7 +1045,7 @@ FrontendGuessSystem( fe_delivery_system_t 
*p_systems, int i_systems )
                 break;
 #endif
             case SYS_DVBT:
-                if ( i_frequency > 50000000 )
+                if ( i_frequency > 50000000 && !(dvb_plp_id) )
                     return SYS_DVBT;
                 break;
             default:
@@ -1137,6 +1164,28 @@ static void FrontendSet( bool b_init )
                  i_guard, i_transmission );
         break;

+    case SYS_DVBT2:
+        p = &dvbt2_cmdseq;
+        p->props[DELSYS].u.data = system;
+        p->props[FREQUENCY].u.data = i_frequency;
+        p->props[INVERSION].u.data = GetInversion();
+        if ( psz_modulation != NULL )
+            p->props[MODULATION].u.data = GetModulation();
+        p->props[BANDWIDTH].u.data = i_bandwidth * 1000000;
+        p->props[FEC_INNER].u.data = GetFECInner(info.caps);
+        p->props[FEC_LP].u.data = GetFECLP(info.caps);
+        p->props[GUARD].u.data = GetGuard();
+        p->props[TRANSMISSION].u.data = GetTransmission();
+        p->props[HIERARCHY].u.data = GetHierarchy();
+        p->props[PLP_ID].u.data = dvb_plp_id;
+
+        msg_Dbg( NULL, "tuning DVB-T2 frontend to f=%d bandwidth=%d 
inversion=%d fec_hp=%d fec_lp=%d hierarchy=%d modulation=%s guard=%d 
transmission=%d PLP_ID=%d ",
+                 i_frequency, i_bandwidth, i_inversion, i_fec, i_fec_lp,
+                 i_hierarchy,
+                 psz_modulation == NULL ? "qam_auto" : psz_modulation,
+                 i_guard, i_transmission, p->props[PLP_ID].u.data );
+        break;
+
 #if DVBAPI_VERSION >= 505
     case SYS_DVBC_ANNEX_A:
 #else
diff --git a/dvblast.c b/dvblast.c
index da2be3a..92c5d23 100644
--- a/dvblast.c
+++ b/dvblast.c
@@ -64,6 +64,7 @@ int i_fenum = 0;
 int i_canum = 0;
 char *psz_delsys = NULL;
 int i_frequency = 0;
+int dvb_plp_id = 0;
 int i_inversion = -1;
 int i_srate = 27500000;
 int i_fec = 999;
@@ -578,6 +579,7 @@ void usage()
     msg_Raw( NULL, "  -r --remote-socket <remote socket>" );
     msg_Raw( NULL, "  -V --version          only display the version" );
     msg_Raw( NULL, "  -Z --mrtg-file <file> Log input packets and errors 
into mrtg-file" );
+    msg_Raw( NULL, "  -9 --dvb-plp-id <number> Switch PLP of the DVB-T2 
transmission (for Russia special)" );
     exit(1);
 }

@@ -600,7 +602,7 @@ int main( int i_argc, char **pp_argv )
         usage();

     /*
-     * The only short options left are: 346789
+     * The only short options left are: 34678
      * Use them wisely.
      */
     static const struct option long_options[] =
@@ -613,6 +615,7 @@ int main( int i_argc, char **pp_argv )
         { "adapter",         required_argument, NULL, 'a' },
         { "frontend-number", required_argument, NULL, 'n' },
         { "delsys",          required_argument, NULL, '5' },
+        { "dvb-plp-id",      required_argument, NULL, '9' },
         { "frequency",       required_argument, NULL, 'f' },
         { "fec-inner",       required_argument, NULL, 'F' },
         { "rolloff",         required_argument, NULL, 'R' },
@@ -664,7 +667,7 @@ int main( int i_argc, char **pp_argv )
         { 0, 0, 0, 0 }
     };

-    while ( (c = getopt_long(i_argc, pp_argv, 
"q::c:r:t:o:i:a:n:5:f:F:R:s:S:k:v:pb:I:m:P:K:G:H:X:O:uwUTL:E:d:D:A:lg:zCWYeM:N:j:J:B:x:Q:hVZ:y:0:1:2:", 
long_options, NULL)) != -1 )
+    while ( (c = getopt_long(i_argc, pp_argv, 
"q::c:r:t:o:i:a:n:5:f:F:R:s:S:k:v:pb:I:m:P:K:G:H:X:O:uwUTL:E:d:D:A:lg:zCWYeM:N:j:J:B:x:Q:hVZ:y:0:1:2:9:", 
long_options, NULL)) != -1 )
     {
         switch ( c )
         {
@@ -738,6 +741,10 @@ int main( int i_argc, char **pp_argv )
             psz_delsys = optarg;
             break;

+        case '9':
+           dvb_plp_id = strtol( optarg, NULL, 0 );
+           break;
+
         case 'f':
             if (optarg && optarg[0] != '-')
                 i_frequency = strtol( optarg, NULL, 0 );
diff --git a/dvblast.h b/dvblast.h
index fbd62a8..a94151b 100644
--- a/dvblast.h
+++ b/dvblast.h
@@ -203,6 +203,7 @@ extern int i_canum;
 extern char *psz_delsys;
 extern int i_dvr_buffer_size;
 extern int i_frequency;
+extern int dvb_plp_id;
 extern int i_srate;
 extern int i_satnum;
 extern int i_uncommitted;


More information about the dvblast-devel mailing list