summaryrefslogtreecommitdiff
path: root/dvb-spec/API/dvb_api/demux_mod.xml
blob: c364679770bbd7df8481253b18853c054700640b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><title>
		 	linuxtv.org|DVB Demux Kernel API</title></head><body
bgcolor="#000000" link="#ffcc00" text="#ffffff" vlink="#ffdd00"><table
border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><table
border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td
width="610"><table border="0" cellpadding="0" cellspacing="0"><tr
valign="top"><td><table border="0" cellpadding="0" cellspacing="0"
width="180"><tr align="right" valign="top"><td><img height="30"
src="/images/top01.gif" width="180"></td></tr><tr><td align="center"
height="38" valign="bottom"><img border="0" height="38"
src="/images/cimlogo02.gif" width="45"></td></tr></table></td><td><table
border="0" cellpadding="0" cellspacing="0" width="50"><tr><td><img
height="30" src="/images/top02.gif" width="284"></td></tr><tr><td><img
height="45" src="/images/top06.gif" width="20">&nbsp;
					
				</td></tr></table></td><td><table border="0" cellpadding="0"
cellspacing="0" width="170"><tr><td background="/images/squares05.gif"
colspan="2"><img height="68" src="/images/squares04.gif"
width="32"></td></tr></table></td></tr><tr><td></td></tr></table></td><td
height="68" valign="top" width="100%"><table border="0" cellpadding="0"
cellspacing="0" width="100%"><tr><td background="/images/squares05.gif"
height="68"
width="100%">&nbsp;</td></tr></table></td></tr></table></td></tr><tr><td height="30">
					&nbsp;
				</td></tr></table><table border="0" cellpadding="0"
cellspacing="0"><tr><td width="181"><table border="0" cellpadding="0"
cellspacing="0" width="181"><tr><td bgcolor="#000000" valign="top"
width="20"><img height="22" src="/images/gruen.gif" width="20"></td><td
bgcolor="#003d19" valign="top" width="19"><img height="22"
src="/images/pfeilgruen.gif" width="19"></td><td bgcolor="#000000"
valign="top" width="2"></td><td bgcolor="#003d19" width="120"><a
href="http://www.convergence.de"><font color="#ffcc00"
face="arial, helvetica" size="2"><b>
												&nbsp;convergence.de
											</b></font></a></td><td align="right" bgcolor="#003d19"
valign="bottom" width="20"><img height="22"
src="/images/eckeswgruen.gif" width="8"></td></tr><tr><td
height="2"></td></tr><tr><td bgcolor="#000000" valign="top"
width="20"><img height="22" src="/images/gruen.gif" width="20"></td><td
bgcolor="#003d19" valign="top" width="19"><img height="22"
src="/images/pfeilgruen.gif" width="19"></td><td bgcolor="#000000"
valign="top" width="2"></td><td bgcolor="#003d19" width="120"><a
href="http://www.cryptolabs.org"><font color="#ffcc00"
face="arial, helvetica" size="2"><b>
											&nbsp;cryptolabs.org</b></font></a></td><td align="right"
bgcolor="#003d19" valign="bottom" width="20"><img height="22"
src="/images/eckeswgruen.gif" width="8"></td></tr><tr><td
height="2"></td></tr><tr><td bgcolor="#000000" valign="top"
width="20"><img height="22" src="/images/gruen.gif" width="20"></td><td
bgcolor="#003d19" valign="top" width="19"><img height="22"
src="/images/pfeilgruen.gif" width="19"></td><td bgcolor="#000000"
valign="top" width="2"></td><td bgcolor="#003d19" width="120"><a
href="http://www.directfb.org"><font color="#ffcc00"
face="arial, helvetica" size="2"><b>
											&nbsp;directfb.org
											</b></font></a></td><td align="right" bgcolor="#003d19"
valign="bottom" width="20"><img height="22"
src="/images/eckeswgruen.gif" width="8"></td></tr><tr><td
height="2"></td></tr><tr><td bgcolor="#000000" valign="top"
width="20"><img height="22" src="/images/gleb.gif" width="20"></td><td
bgcolor="#ffcc00" valign="top" width="19"><img height="22"
src="/images/pfeilgelb.gif" width="19"></td><td bgcolor="#000000"
valign="top" width="2"></td><td bgcolor="#ffcc00" width="120"><a
href="/"><font color="#003d19" face="arial, helvetica" size="2"><b>
											&nbsp;linuxtv.org
											</b></font></a></td><td align="right" bgcolor="#ffcc00"
valign="bottom" width="20"><img height="22" src="/images/eckeswgelb.gif"
width="8"></td></tr><tr><td height="2"></td></tr></table></td><td width="20">
					&nbsp;
				</td><td valign="top" width="500"><img height="60"
src="/images/linuxtv.gif" width="245"></td></tr><tr><td align="left"
valign="top" width="181"><table bgcolor="#ffcc00" border="0"
cellpadding="0" cellspacing="0" width="185"><tr><td bgcolor="#000000"
valign="top" width="20"><img height="22" src="/images/gleb.gif"
width="20"></td><td bgcolor="#ffcc00" width="19"><img height="22"
src="/images/arrow_main.gif" width="19"></td><td bgcolor="#000000"
width="2"></td><td bgcolor="#ffcc00" width="131">
			&nbsp;<a href="/"><font color="#003d19" face="helvetica"
size="2"><b>linuxtv</b></font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" colspan="5"
height="2"></td></tr><tr><td bgcolor="#000000" valign="top"
width="20"><img height="22" src="/images/gleb.gif" width="20"></td><td
bgcolor="#ffcc00" width="19"><img height="22"
src="/images/arrow_main.gif" width="19"></td><td bgcolor="#000000"
width="2"></td><td bgcolor="#ffcc00" width="131">
			&nbsp;<a href="/projects.xml"><font color="#003d19" face="helvetica"
size="2"><b>projects</b></font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" colspan="5"
height="2"></td></tr><tr><td bgcolor="#000000" valign="top"
width="20"><img height="22" src="/images/gleb.gif" width="20"></td><td
bgcolor="#ffcc00" width="19"><img height="22"
src="/images/arrow_main_open.gif" width="19"></td><td bgcolor="#000000"
width="2"></td><td bgcolor="#ffcc00" width="131">
			&nbsp;<a href="/developer/"><font color="#003d19" face="helvetica"
size="2"><b>developer</b></font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" width="20"></td><td
bgcolor="#ffcc00" width="19">&nbsp;</td><td bgcolor="#000000"
width="2"></td><td width="131"><img height="13"
src="/images/arrow_sub_open.gif" width="13">
			&nbsp;<a href="/developer/dvb.xml"><font color="#000000"
face="helvetica" size="2">DVB</font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" width="20"></td><td
width="19">&nbsp;</td><td bgcolor="#000000" width="2"></td><td width="131">&nbsp;
			<img height="13" src="/images/space_sub.gif" width="13"><img
height="13" src="/images/kulleropen.gif" width="13"><a
href="/developer/dvb_api.xml"><font color="#000000" face="helvetica" size="2">
				&nbsp;API</font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" width="20"></td><td
bgcolor="#ffcc00" width="19">&nbsp;</td><td bgcolor="#000000"
width="2"></td><td width="131"><img height="13"
src="/images/arrow_sub.gif" width="13">
			&nbsp;<a href="/developer/dvd.xml"><font color="#000000"
face="helvetica" size="2">DVD</font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" width="20"></td><td
bgcolor="#ffcc00" width="19">&nbsp;</td><td bgcolor="#000000"
width="2"></td><td width="131"><img height="13"
src="/images/arrow_sub.gif" width="13">
			&nbsp;<a href="/developer/mbone.xml"><font color="#000000"
face="helvetica" size="2">Mbone</font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" width="20"></td><td
bgcolor="#ffcc00" width="19">&nbsp;</td><td bgcolor="#000000"
width="2"></td><td width="131"><img height="13"
src="/images/arrow_sub.gif" width="13">
			&nbsp;<a href="/cvs/"><font color="#000000" face="helvetica"
size="2">CVS</font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" colspan="5"
height="2"></td></tr><tr><td bgcolor="#000000" valign="top"
width="20"><img height="22" src="/images/gleb.gif" width="20"></td><td
bgcolor="#ffcc00" width="19"><img height="22"
src="/images/arrow_main.gif" width="19"></td><td bgcolor="#000000"
width="2"></td><td bgcolor="#ffcc00" width="131">
			&nbsp;<a href="/download/"><font color="#003d19" face="helvetica"
size="2"><b>download</b></font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" colspan="5"
height="2"></td></tr><tr><td bgcolor="#000000" valign="top"
width="20"><img height="22" src="/images/gleb.gif" width="20"></td><td
bgcolor="#ffcc00" width="19"><img height="22"
src="/images/arrow_main.gif" width="19"></td><td bgcolor="#000000"
width="2"></td><td bgcolor="#ffcc00" width="131">
			&nbsp;<a href="/contact.xml"><font color="#003d19" face="helvetica"
size="2"><b>contact</b></font></a></td><td bgcolor="#000000"
width="9"></td></tr><tr><td bgcolor="#000000" colspan="5"
height="2"></td></tr></table></td><td width="20">
					&nbsp;
				</td><td valign="top" width="500"><font color="#ffcc00" face="arial, helvetica"><h2>DVB Demux Kernel API</h2></font>

	<p>
	The demux kernel API gives access to the demuxer of the DVB hardware
	to other kernel modules which implement devices like the 
	<a href="demux.xml">demux device</a> or generic DVB network devices.
	</p>

	<p>
	The function calls defined in the include file 
	<a href="demux.h">demux.h</a> are described in detail below:
	</p>

	<p>
	<font face="arial, helvetica" size="+1">Demux Directory API</font>

	<p>
	The demux directory is a Linux kernel-wide facility for registering and 
	accessing the MPEG-2 TS demuxes in the system. Run-time registering and 
	unregistering of demux drivers is possible using this API. 
	</p>
	<p>
	All demux drivers in the directory implement the abstract interface dmx_demux_t.
	</p>
	
<p>
<pre>
int dmx_register_demux ( dmx_demux_t* demux )

    Description

	This function makes a demux driver interface available to the Linux kernel. 
	It is usually called by the init_module() function of the kernel module that
	contains the demux driver. The caller of this function is responsible for 
	allocating dynamic or static memory for the demux structure and for initializing
	its fields before calling this function. 
	The memory allocated for the demux structure must not be freed before calling
        dmx_unregister_demux(),

    Returns
    
	0				The command was successfully performed.

        -EEXIST                         A demux with the same value of the id field
                                        already stored in the directory.

        -ENOSPC                         No space left in the directory.



</pre>
</p>
<p>
<pre>

int dmx_unregister_demux ( dmx_demux_t* demux )

    Parameters

	dmx_demux_t* demux	    I/O Pointer to the demux API and instance variables.

    Description

	This function is called to indicate that the given demux interface is no longer
	available. The caller of this function is responsible for freeing the memory of
	the demux structure, if it was dynamically allocated before calling 
	dmx_register_demux().
	The cleanup_module() function of the kernel module that contains the demux 
	driver should call this function. Note that this function fails if the demux 
	is currently in use, i.e., release_demux() has not been called for the 
	interface.

    Returns

	0				The command was successfully performed.

        -ENODEV                         No such demux registered.

        -EBUSY                          Demux is currently in use.



</pre>
</p>
<p>
<pre>

struct list_head* dmx_get_demuxes ()

    Description

	Provides the caller with the list of registered demux interfaces, using the 
	standard list structure defined in the include file linux/list.h. 
	The include file demux.h defines the macro DMX_DIR_ENTRY() for converting an 
	element of the generic type struct list_head* to the type dmx_demux_t*.
        The caller must not free the memory of any of the elements obtained via this
	function call.

    Returns

	A list of demux interfaces, or NULL in the case of an empty list.



</pre>
</p>
</p>


<p>
<font face="arial, helvetica" size="+1">Demux API</font>
<p>
	The demux API should be implemented for each demux in the system. It is used to
        select the TS source of a demux and to manage the demux resources. When the
        demux client allocates a resource via the demux API, it receives a pointer 
	to the API of that resource.
</p>
<p>
        Each demux receives its TS input from a DVB front-end or from the memory, as 
	set via the demux API. In a system with more than one front-end, the API can 
	be used to select one of the DVB front-ends as a TS source for a demux, unless
	this is fixed in the HW platform. The demux API only controls front-ends 
	regarding their connections with demuxes; the APIs used to set the other 	
	front-end parameters, such as tuning, are not defined in this document.
</p>
<p>
        The functions that implement the abstract interface demux_t should be defined
	static or module private and registered to the Demux Directory for external
        access. It is not necessary to implement every function in the demux_t struct,
	however (for example, a demux interface might support Section filtering, but 
	not TS or PES filtering). The API client is expected to check the value of any
	function pointer before calling the function: the value of NULL means &quot;function
	not available&quot;.
</p>
<p>
        Whenever the functions of the demux API modify shared data, the possibilities
	of lost update and race condition problems should be addressed, e.g. by 
	protecting parts of code with mutexes. This is especially important on 
	multi-processor hosts.
</p>
<p>
        Note that functions called from a bottom half context must not sleep, at least
	in the 2.2.x kernels. Even a simple memory allocation can result in a kernel
	thread being put to sleep if swapping is needed. For example, the Linux kernel
	calls the functions of a network device interface from a bottom half context.
	Thus, if a demux API function is called from network device code, the function
	must not sleep.
</p>
<p>
<pre>

int open ( demux_t* demux )


    Parameters
    
	demux_t* demux		      I Pointer to the demux API and instance data.

    Description

	This function reserves the demux for use by the caller and, if necessary, 
	initializes the demux. When the demux is no longer needed, the function close()
	should be called.
        It should be possible for multiple clients to access the demux at the same time.
	Thus, the function implementation should increment the demux usage count when 
	open() is called and decrement it when close() is called.

    Returns

	0				The command was successfully performed.

        -EUSERS                         Maximum usage count reached.

        -EINVAL                         Bad parameter.



</pre>
</p>
<p>
<pre>

int close ( demux_t* demux )

    Parameters

	demux_t* demux		      I Pointer to the demux API and instance data.

    Description

	The function is called to indicate that the API client does not need to use 
	the demux anymore. As a result of this function, the demux usage count is 
	decremented by one.
        When the usage count drops to zero, any demux resources can be released.

    Returns

	0				The command was successfully performed.

        -ENODEV                         The demux was not in use.

        -EINVAL                         Bad parameter.



</pre>
</p>
<p>
<pre>

int write ( demux_t* demux, const char* buf, size_t count)    

    Parameters

	demux_t* demux		    I/O Pointer to the demux API and instance data.

        const char* buf               I Pointer to the TS data in kernel-space memory.

        size_t length                 I Length of the TS data.



    Description

	This function provides the demux driver with a memory buffer containing TS 
	packets. Instead of receiving TS packets from the DVB front-end, the demux 
	driver software will read packets from the memory. Any clients of this demux 
	with active TS, PES or Section filters will receive filtered data via the Demux
	callback API (see 0). The function returns when all the data in the buffer has
	been consumed by the demux.
	Demux hardware typically cannot read TS from the memory. If this is the case,
        memory-based filtering has to be implemented entirely in software.

    Returns

	0				The command was successfully performed.

        -ENOSYS                         The command is not implemented.

        -EINVAL                         Bad parameter.



</pre>
</p>
<p>
<pre>

int allocate_ts_feed ( dmx_demux_t* demux, dmx_ts_feed_t** feed, dmx_ts_cb callback )

    Parameters

	demux_t* demux		    I/O Pointer to the demux API and instance data.

        dmx_ts_feed_t** feed          O Pointer to the TS feed API and instance data.

        dmx_ts_cb callback            I Pointer to the callback function for
                                        passing received TS packet

    Description

	Allocates a new TS feed, which is used to filter the TS packets carrying a 
	certain PID.
        The TS feed normally corresponds to a hardware PID filter on the demux chip.

    Returns

	0				The command was successfully performed.

        -EBUSY                          No more TS feeds available.
 
	-ENOSYS                         The command is not implemented.

        -EINVAL                         Bad parameters.



</pre>
</p>
<p>
<pre>
int release_ts_feed ( dmx_demux_t* demux, dmx_ts_feed_t* feed)

    Parameters

             dmx_demux_t* demux                        I/O Pointer to the demux API and
                                                             instance data.
             dmx_ts_feed_t* feed                       I     Pointer to the TS feed API and
                                                             instance data.

            Function Detailed Description
            Releases the resources allocated with allocate_ts_feed(). Any filtering in progress
            on the TS feed should be stopped before calling this function.

            Function Returns
             0                                         The command was successfully performed.
             -EINVAL                                   Bad parameters.

</pre>
</p>
<p>
<pre>
allocate_pes_feed()

            TBD



</pre>
</p>
<p>
<pre>
release_pes_feed()

            TBD



</pre>
</p>
<p>
<pre>
int allocate_section_feed ( dmx_demux_t* demux,
             dmx_section_feed_t** 
                                                                            feed,
                                                dmx_section_cb callback )

            Function Parameters
             demux_t* demux                            I/O Pointer to the demux API and
                                                             instance data.
             dmx_section_feed_t** feed                 O     Pointer to the section feed API and

                                                                instance data.
             dmx_section_cb callback                  I         Pointer to the callback function for
                                                                passing received sections

            Function Detailed Description
            Allocates a new section feed, i.e. a demux resource for filtering and receiving sections.
            On platforms with hardware support for section filtering, a section feed is directly
            mapped to the demux HW. On other platforms, TS packets are first PID filtered in
            hardware and a hardware section filter then emulated in software.
            The caller obtains an API pointer of type dmx_section_feed_t as an out parameter.
            Using this API the caller can set filtering parameters and start receiving sections.

            Function Returns
             0                                        The command was successfully performed.
             -EBUSY                                   No more section feeds available.
             -ENOSYS                                  The command is not implemented.
             -EINVAL                                  Bad parameters.

</pre>
</p>
<p>
<pre>

int release_section_feed ( dmx_demux_t* demux,
             dmx_section_feed_t* 
                                                                          feed 
                                                                                  )
            Function Parameters
             dmx_demux_t* demux                            I/O Pointer to the demux API and
                                                                  instance data.
             dmx_section_feed_t* feed                      I      Pointer to the section feed API and
                                                                  instance data.

            Function Detailed Description
            Releases the resources allocated with allocate_section_feed(), including allocated
            filters. Any filtering in progress on the section feed should be stopped before calling
            this function.

            Function Returns
             0                                        The command was successfully performed.
             -EINVAL                                  Bad parameters.


</pre>
</p>
<p>
<pre>

int descramble_mac_address ( dmx_demux_t* demux,
             __u8* 
                                                            buffer1,
             size_t 
                                                             buffer1_length,
                                                   __u8* buffer2,
             size_t 
                                                             buffer2_length,
                                                   __u16 pid )
            Function Parameters
             dmx_demux_t* demux                             I/O Pointer to the demux API and
                                                                   instance data.
             __u8* buffer1                                  I      Pointer to the first byte of the
                                                                   section.
             size_t buffer1_length                          I      Length of the section data,
                                                                   including headers and CRC, in
                                                                   buffer1.
             __u8* buffer2                                  I      Pointer to the tail of the section
                                                                   data, or NULL. The pointer has a
                                                                   non-NULL value if the section wraps
                                                                   past the end of a cyclic buffer.
             size_t buffer2_length                          I      Length of the section data,
                                                                   including headers and CRC, in
                                                                   buffer2
             __u16 pid                                      I      The PID on which the section was
                                                                   received. Useful for obtaining the
                                                                   descrambling key, e.g. from a DVB
                                                                   Common Access facility.

            Function Detailed Description
            This function runs a descrambling algorithm on the destination MAC address field of a
            DVB Datagram Section, replacing the original address with its unencrypted version.
            Otherwise, the description on the function descramble_section_payload() applies
            also to this function.

            Function Returns
             0                                         The command was successfully performed.
             -ENOSYS                                   No descrambling facility available.
             -EINVAL                                   Bad parameters.




</pre>
</p>
<p>
<pre>

int descramble_section_payload (           dmx_demux_t* demux,
             __u8* 
                                                                  buffer1,
             size_t 
                                                                   buffer1_length,
                                                       __u8* buffer2,
             size_t 
                                                                   buffer2_length,
                                                       __u16 pid )
            Function Parameters
             dmx_demux_t* demux                            I/O Pointer to the demux API and
                                                                  instance data.
             __u8* buffer1                                 I/O Pointer to the first byte of the
                                                                  section.
             size_t buffer1_length                         I      Length of the section data,
                                                                  including headers and CRC, in
                                                                  buffer1.
             __u8* buffer2                                 I      Pointer to the tail of the section
                                                                  data, or NULL. The pointer has a
                                                                  non-NULL value if the section wraps
                                                                  past the end of a cyclic buffer.
             size_t buffer2_length                         I      Length of the section data,
                                                                  including headers and CRC, in
                                                                  buffer2
             __u16 pid                                     I      The PID on which the section was
                                                                  received. Useful for obtaining the
                                                                  descrambling key, e.g. from a DVB
                                                                  Common Access facility.

            Function Detailed Description
            This function runs a descrambling algorithm on the payload of a DVB Datagram
            Section, replacing the original payload with its unencrypted version. The function will
            be called from the demux API implementation; the API client need not call this function
            directly.
            Section-level scrambling algorithms are currently standardized only for DVB-RCC
            (return channel over 2-directional cable TV network) systems. For all other DVB
            networks, encryption schemes are likely to be proprietary to each data broadcaster.
            Thus, it is expected that this function pointer will have the value of NULL (i.e., function
            not available) in most demux API implementations. Nevertheless, it should be possible
            to use the function pointer as a hook for dynamically adding a &quot;plug-in&quot; descrambling
            facility to a demux driver.


            While this function is not needed with hardware-based section descrambling, the
            descramble_section_payload function pointer can be used to override the default
            hardware-based descrambling algorithm: if the function pointer has a non-NULL value,
            the corresponding function should be used instead of any descrambling hardware.

            Function Returns
             0                                           The command was successfully performed.
             -ENOSYS                                     No descrambling facility available.
             -EINVAL                                     Bad parameters.


</pre>
</p>
<p>
<pre>

int add_frontend ( dmx_demux_t* demux,
             dmx_frontend_t* 
                                                          frontend);

            Function Parameters
             dmx_demux_t* demux                        I/O Pointer to the demux API and instance
                                                             data.
             dmx_frontend_t* frontend                  I/O Pointer to the front-end instance data.

            Function Detailed Description
            Registers a connectivity between a demux and a front-end, i.e., indicates that the
            demux can be connected via a call to connect_frontend() to use the given front-end
            as a TS source. The client of this function has to allocate dynamic or static memory for
            the frontend structure and initialize its fields  before calling this function.
            This function is normally called during the driver initialization. The caller must not free
            the memory of the frontend struct before successfully calling remove_frontend().

            Function Returns
             0                                      The command was successfully performed.
             -EEXIST                                A front-end with the same value of the id field
                                                    already registered.
             -EINUSE                                The demux is in use.
             -ENOMEM                                No more front-ends can be added.
             -EINVAL                                Bad parameters.

</pre>
</p>
<p>
<pre>

int remove_frontend ( dmx_demux_t* demux,
                                         dmx_frontend_t* frontend )
            Function Parameters
             dmx_demux_t* demux                   I/O       Pointer to the demux API and instance
                                                            data.
             dmx_frontend_t* frontend             I/O       Pointer to the front-end instance data.

            Function Detailed Description
            Indicates that the given front-end, registered by a call to add_frontend(), can no
            longer be connected as a TS source by this demux. The function should be called
            when a front-end driver or a demux driver is removed from the system. If the front-end
            is in use, the function fails with the return value of &shy;EBUSY.
            After succesfully calling this function, the caller can free the memory of the frontend
            struct if it was dynamically allocated before the add_frontend() operation.

            Function Returns
             0                                     The command was successfully performed.
             -EINVAL                               Bad parameters.
             -EBUSY                                The front-end is in use, i.e. a call to
                                                   connect_frontend() has not been followed by
                                                   a call to disconnect_frontend().


</pre>
</p>
<p>
<pre>

struct list_head* get_frontends ( dmx_demux_t* demux )
            Function Parameters
             dmx_demux_t* demux                             I    Pointer to the demux API and
                                                                 instance data.

            Function Detailed Description
            Provides the APIs of the front-ends that have been registered for this demux. Any of
            the front-ends obtained with this call can be used as a parameter for
            connect_frontend().


            The include file demux.h contains the macro DMX_FE_ENTRY() for converting an
            element of the generic type struct list_head* to the type dmx_frontend_t*.
            The caller must not free the memory of any of the elements obtained via this function
            call.

            Function Returns
            A list of front-end interfaces, or NULL in the case of an empty list.

</pre>
</p>
<p>
<pre>

int connect_frontend ( dmx_demux_t* demux,
                                           dmx_frontend_t* frontend )
            Function Parameters
             dmx_demux_t* demux                   I/O       Pointer to the demux API and instance
                                                            data.
             dmx_frontend_t* frontend             I/O       Pointer to the front-end instance data.

            Function Detailed Description
            Connects the TS output of the front-end to the input of the demux. A demux can only
            be connected to a front-end registered to the demux with the function
            add_frontend().
            It may or may not be possible to connect multiple demuxes to the same front-end,
            depending on the capabilities of the HW platform. When not used, the front-end should
            be released by calling disconnect_frontend().

            Function Returns
             0                                     The command was successfully performed.
             -EINVAL                               Bad parameters.
             -EBUSY                                The front-end is in use.

</pre>
</p>
<p>
<pre>

int disconnect_frontend ( dmx_demux_t* demux )


            Function Parameters
             dmx_demux_t* demux               I/O Pointer to the demux API and instance data.

            Function Detailed Description
            Disconnects the demux and a front-end previously connected by a
            connect_frontend() call.

            Function Returns
             0                                        The command was successfully performed.
             -EINVAL                                  Bad parameters.


</pre>
</p>
</p>

<p>
<font face="arial, helvetica" size="+1">Demux Callback API</font>
<p>
	This kernel-space API comprises the callback functions that deliver filtered data to the
        demux client. Unlike the other APIs, these API functions are provided by the client and
            called from the demux code.
</p>
<p>
            The function pointers of this abstract interface are not packed into a structure as in the
            other demux APIs, because the callback functions are registered and used
            independent of each other. As an example, it is possible for the API client to provide
            several callback functions for receiving TS packets and no callbacks for PES packets
            or sections.
</p>
<p>
            The functions that implement the callback API need not be re-entrant: when a demux
            driver calls one of these functions, the driver is not allowed to call the function again
            before the original call returns. If a callback is triggered by a hardware interrupt, it is
            recommended to use the Linux &quot;bottom half&quot; mechanism or start a tasklet instead of
            making the callback function call directly from a hardware interrupt.

</p>
<p>
<pre>
int dmx_ts_cb ( __u8* buffer1, size_t buffer1_length, 
		__u8* buffer2, size_t buffer2_length,
                dmx_ts_feed_t* source, dmx_success_t success )

    Parameters

	__u8* buffer1		      I Pointer to the start of the filtered TS packets.

        size_t buffer1_length         I Length of the TS data in buffer1.

        __u8* buffer2                 I Pointer to the tail of the filtered TS packets, or NULL.

        size_t buffer2_length         I Length of the TS data in buffer2.

        dmx_ts_feed_t* source         I Indicates which TS feed is the source of the callback.

        dmx_success_t success         I Indicates if there was an error in TS reception.

    Description

	This function, provided by the client of the demux API, is called from the 
	demux code. The function is only called when filtering on this TS feed has 
	been enabled using the start_filtering() function. If conflict resolution 
	is used (see Error! Reference source not found.), no callbacks are made to 
	clients that have been put &quot;on hold&quot; regarding a TS Feed resource.
        Any TS packets that match the filter settings are copied to a cyclic buffer. 
	The filtered TS packets are delivered to the client using this callback 
	function. The size of the cyclic buffer is controlled by the 
	circular_buffer_size parameter of the set() function in the TS Feed API. It is
	expected that the buffer1 and buffer2 callback parameters point to addresses 
	within the circular buffer, but other implementations are also
        possible. Note that the called party should not try to free the memory the
	buffer1 and buffer2 parameters point to.
        When this function is called, the buffer1 parameter typically points to the
	start of the first undelivered TS packet within a cyclic buffer. The buffer2 
	buffer parameter is normally NULL, except when the received TS packets have
	crossed the last address of the cyclic buffer and &quot;wrapped&quot; to the beginning
	of the buffer. In the latter case the buffer1 parameter would contain an 
	address within the cyclic buffer, while the buffer2 parameter would contain 
	the first address of the cyclic buffer.
        The number of bytes delivered with this function (i.e. buffer1_length  +
        buffer2_length) is usually equal to the value of callback_length parameter given
        in the set() function, with one exception: if a timeout occurs before receiving
        callback_length bytes of TS data, any undelivered packets are immediately
        delivered to the client by calling this function. The timeout duration is 
	controlled by the set() function in the TS Feed API.
        If a TS packet is received with errors that could not be fixed by the TS-level
	forward error correction (FEC), the Transport_error_indicator flag of the TS 
	packet header should be set. The TS packet should not be discarded, as the 
	error can possibly be corrected by a higher layer protocol.
        If the called party is slow in processing the callback, it is possible that 
	the circular buffer eventually fills up. If this happens, the demux driver 
	should discard any TS packets received while the buffer is full. The error 
	should be indicated to the client on the next callback by setting the success
	parameter to the value of DMX_OVERRUN_ERROR.

    Returns

	0				Continue filtering.

       -1                               Stop filtering - has the same effect as a call
                                        to stop_filtering() on the TS Feed API.



</pre>
</p>
<p>
<pre>

dmx_pes_cb()

	TBD

</pre>
</p>
<p>
<pre>

int dmx_section_cb ( __u8* buffer1,
             size_t 
                                                   buffer1_length,
             __u8* 
                                               buffer2,
                                 size_t buffer2_length,
             dmx_section_filter_t* 
                                                                      source,
                                       dmx_success_t success )

            Function Parameters
             __u8* buffer1                    I       Pointer to the start of the filtered section, e.g.
                                                      within the cyclic buffer of the demux driver.
             size_t buffer1_length            I       Length of the filtered section data in buffer1,
                                                      including headers and CRC.
             __u8* buffer2                            Pointer to the tail of the filtered section data, or
                                                      NULL. Useful to handle the wrapping of a cyclic
                                                      buffer.
             size_t buffer2_length                    Length of the filtered section data in buffer2,
                                                      including headers and CRC.
             dmx_section_filter_t*            I       Indicates the filter that triggered the callback.
             filter
             dmx_success_t success            I       Indicates if there was an error in section
                                                      reception.

            Function Detailed Description
            This function, provided by the client of the demux API, is called from the demux code.
            The function is only called when filtering of sections has been enabled using the
            function start_filtering() of the section feed API.
            When the demux driver has received a complete section that matches at least one
            section filter, the client is notified via this callback function. Normally this function is
            called for each received section; however, it is also possible to deliver multiple sections
            with one callback, for example when the system load is high.
            If an error occurs while receiving a section, this function should be called with the
            corresponding error type set in the success field, whether or not there is data to
            deliver.
            The Section Feed implementation should maintain a cyclic buffer for received sections.
            However, this is not necessary if the Section Feed API is implemented as a client of


            the TS Feed API, because the TS Feed implementation then buffers the
            received data.
            The size of the circular buffer can be configured using the set() function in the
            Section Feed API. If there is no room in the circular buffer when a new section is
            received, the section must be discarded. If this happens, the value of the success
            parameter should be DMX_OVERRUN_ERROR on the next callback.

            Function Returns
             0                                         Continue filtering.
             -1                                        Stop filtering - has the same effect as a call
                                                       to stop_filtering() on the Section Feed
                                                       API.

</pre>
</p>

</p>

<p>
<font face="arial, helvetica" size="+1">TS Feed API</font>
<p>
            A TS feed is typically mapped to a hardware PID filter on the demux chip. Using this
            API, the client can set the filtering properties to start/stop filtering TS packets on a
            particular TS feed. The API is defined as an abstract interface of the type
            dmx_ts_feed_t.
</p>
<p>
            The functions that implement the interface should be defined static or module
            private. The client can get the handle of a TS feed API by calling the function
            allocate_ts_feed() in the demux API.
</p>
<p>
<pre>

int set ( dmx_ts_feed_t* feed,
             __u16 
                                    pid,
                           size_t callback_length,
             size_t 
                                     cyclic_buffer_size,
             int 
                               descramble,
                           struct timespec timeout)

    Parameters

             dmx_ts_feed_t* feed                       I/O Pointer to the TS feed API and
                                                               instance data.
             __u16 pid                                 I       PID value to filter. Only the TS
                                                               packets carrying the specified PID will
                                                               be passed to the API client.
             size_t callback_length                    I       Number of bytes to deliver with each
                                                               call to the dmx_ts_cb() callback
                                                               function. The value of this
                                                               parameter should be a multiple of
                                                               188.

             size_t cyclic_buffer_size                    I     Size of the cyclic buffer for the filtered
                                                                TS packets.
             int descramble                               I     If non-zero, descramble the filtered
                                                                TS packets.
             struct timespec timeout                      I     Maximum time to wait before
                                                                delivering received TS packets to the
                                                                client.

            Function Detailed Description
            This function sets the parameters of a TS feed. Any filtering in progress on the TS feed
            must be stopped before calling this function.

            Function Returns
             0                                            The command was successfully performed.
             -ENOMEM                                      Not enough memory for the requested
                                                          buffer size.
             -ENOSYS                                      No descrambling facility available for TS
                                                          packets.
             -EINVAL                                      Bad parameters.

</pre>
</p>
<p>
<pre>

int start_filtering ( dmx_ts_feed_t* feed )

    Parameters
 
             dmx_ts_feed_t* feed                    I Pointer to the TS feed API and instance data.

            Function Detailed Description
            Starts filtering TS packets on this TS feed, according to its settings. The PID value to
            filter can be set by the API client. All matching TS packets are delivered
            asynchronously to the client, using the callback function registered with
            allocate_ts_feed().

            Function Returns
             0                                        The command was successfully performed.
             -EINVAL                                  Bad parameters.


</pre>
</p>
<p>
<pre>

int stop_filtering ( dmx_ts_feed_t* feed )

    Parameters

	dmx_ts_feed_t* feed	    I/O Pointer to the TS feed API and instance data.

    Description

	Stops filtering TS packets on this TS feed.

    Returns

	0				The command was successfully performed.

        -EINVAL                         Bad parameters.



</pre>
</p>
</p>

<p>
<font face="arial, helvetica" size="+1">PES Feed API</font>
<p>
            TBD
</p>
</p>

<p>
<font face="arial, helvetica" size="+1">Section Feed API</font>
<p>
	A section feed is a resource consisting of a PID filter and a set of section filters. Using
            this API, the client can set the properties of a section feed and to start/stop filtering.
            The API is defined as an abstract interface of the type dmx_section_feed_t.
            The functions that implement the interface should be defined static or module
            private. The client can get the handle of a section feed API by calling the function
            allocate_section_feed() in the demux API.
</p>
<p>
            On demux platforms that provide section filtering in hardware, the Section Feed API
            implementation provides a software wrapper for the demux hardware. Other platforms
            may support only PID filtering in hardware, requiring that TS packets are converted to
            sections in software. In the latter case the Section Feed API implementation can be a
            client of the TS Feed API.
</p>

<p>
<pre>

int set ( dmx_section_feed_t* feed, __u16 pid, size_t circular_buffer_size, 
	  int descramble, int check_crc )

    Parameters

	dmx_section_feed_t* feed                  I/O Pointer to the section feed API and
                                                                instance data.
             __u16 pid                                I         PID value to filter; only the TS packets
                                                                carrying the specified PID will be
                                                                accepted.
             size_t circular_buffer_size              I         Size of the cyclic buffer for filtered
                                                                sections.
             int descramble                           I         If non-zero, descramble any sections
                                                                that are scrambled.
             int check_crc                            I         If non-zero, check  the CRC values of
                                                                filtered sections.

            Function Detailed Description
            This function sets the parameters of a section feed. Any filtering in progress on the
            section feed must be stopped before calling this function.
            If descrambling is enabled, the payload_scrambling_control and
            address_scrambling_control fields of received DVB datagram sections should be
            observed. If either one is non-zero, the section should be descrambled either in
            hardware or using the functions descramble_mac_address() and
            descramble_section_payload() of the demux API. Note that according to the
            MPEG-2 Systems specification [3], only the payloads of private sections can be
            scrambled while the rest of the section data must be sent in the clear.

            Function Returns
             0                                     The command was successfully performed.
             -ENOMEM                               Not enough memory available for the requested
                                                   buffer size.
             -ENOSYS                               No descrambling facility available for sections.
             -EINVAL                               Bad parameters.

</pre>
</p>
<p>
<pre>

int allocate_filter(dmx_section_feed_t* feed, dmx_section_filter_t** filter)

    Parameters
             dmx_section_feed_t* feed                      I/O Pointer to the section feed API and
                                                                 instance data.
             dmx_section_filter_t** filter                 O     Pointer to the allocated filter.


            Function Detailed Description
            This function is used to allocate a section filter on the demux. It should only be called
            when no filtering is in progress on this section feed. If a filter cannot be allocated, the
            function fails with -ENOSPC. See below for the format of the section filter struct provided
            as an out parameter:
                   typedef struct {
                           __u8 filter_value [DMX_MAX_FILTER_SIZE];
                           __u8 filter_mask [DMX_MAX_FILTER_SIZE];
                            struct dmx_section_feed_s* parent;  /* Back-pointer */
                           void* priv; /* Private data of the client */
                   } dmx_section_filter_t;

            The bitfields filter_mask and filter_value should only be modified when no
            filtering is in progress on this section feed. filter_mask controls which bits of
            filter_value are compared with the section headers/payload. On a binary value of 1
            in filter_mask, the corresponding bits are compared. The filter only accepts sections
            that are equal to filter_value in all the tested bit positions. Any changes to the
            values of filter_mask and filter_value are guaranteed to take effect only when
            the start_filtering()  function is called next time. The parent pointer in the struct
            is initialized by the API implementation to the value of the feed parameter. The priv
            pointer is not used by the API implementation, and can thus be freely utilized by the
            caller of this function. Any data pointed to by the priv pointer is available to the
            recipient of the dmx_section_cb() function call.
            While the maximum section filter length (DMX_MAX_FILTER_SIZE) is currently set at 16
            bytes, hardware filters of that size are not available on all platforms. Therefore, section
            filtering will often take place first in hardware, followed by filtering in software for the
            header bytes that were not covered by a hardware filter. The filter_mask field can be
            checked to determine how many bytes of the section filter are actually used, and if the
            hardware filter will suffice. Additionally, software-only section filters can optionally be
            allocated to clients when all hardware section filters are in use.
            Note that on most demux hardware it is not possible to filter on the section_length field
            of the section header &shy; thus this field is ignored, even though it is included in
            filter_value and filter_mask fields.

            Function Returns
             0                                          The command was successfully performed.
             -ENOSPC                                    No filters of given type and length available.
             -EINVAL                                    Bad parameters.

</pre>
</p>
<p>
<pre>
int release_filter ( dmx_section_feed_t* feed, dmx_section_filter_t* filter)

    Parameters
             dmx_section_feed_t* feed I/O Pointer to the section feed API and instance
                                                       data.
             dmx_section_filter_t*              I/O Pointer to the instance data of a section filter.
             filter

            Function Detailed Description
            This function releases all the resources of a previously allocated section filter. The
            function should not be called while filtering is in progress on this section feed. After
            calling this function, the caller should not try to dereference the filter pointer.

            Function Returns
             0                                        The command was successfully performed.
             -ENODEV                                  No such filter allocated.
             -EINVAL                                  Bad parameters.

</pre>
</p>
<p>
<pre>
int start_filtering ( dmx_section_feed_t* feed )

    Parameters
             dmx_section_feed_t* feed                     I/O Pointer to the section feed API and
                                                                instance data.

            Function Detailed Description
            Starts filtering sections on this section feed, according to its settings. Sections are first
            filtered based on their PID and then matched with the section filters allocated for this
            feed. If the section matches the PID filter and at least one section filter, it is delivered
            to the API client. The section is delivered asynchronously using the callback function
            registered with allocate_section_feed().

            Function Returns
             0                                            The command was successfully performed.
             -EINVAL                                      Bad parameters.

</pre>
</p>
<p>
<pre>
int stop_filtering ( dmx_section_feed_t* feed )

    Parameters

	dmx_section_feed_t* feed	    I/O Pointer to the section feed API and instance data.

    Description

	Stops filtering sections on this section feed. Note that any changes to the 
	filtering parameters (filter_value, filter_mask, etc.) should only be made 
	when filtering is stopped.

    Returns

	0					The command was successfully performed.

        -EINVAL                                 Bad parameters.



</pre>
</p>
	</p>
	</td></tr></table></body></html>

<!-- This page was served in 2918 milliseconds by Cocoon 1.7.4 -->