📄 kdapi.tex
字号:
dmx\_ts\_feed\_t* source & Indicates which TS feed is the source of the callback.\\ dmx\_success\_t success & Indicates if there was an error in TS reception. }{ 0 & Continue filtering.\\ -1& Stop filtering - has the same effect as a call to stop\_filtering() on the TS Feed API.}\kifunction{dmx\_section\_cb()}{ 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); }{ 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 circular 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. }{ \_\_u8* buffer1 & Pointer to the start of the filtered section, e.g. within the circular buffer of the demux driver.\\ size\_t buffer1\_length & 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 circular buffer.\\ size\_t buffer2\_length & Length of the filtered section data in buffer2, including headers and CRC.\\ dmx\_section\_filter\_t* filter & Indicates the filter that triggered the callback.\\ dmx\_success\_t success & Indicates if there was an error in section reception. }{ 0 & Continue filtering.\\ -1& Stop filtering - has the same effect as a call to stop\_filtering() on the Section Feed API.}\clearpage\devsubsec{TS Feed API}A TS feed is typically mapped to a hardware PID filter on the demux chip. Using thisAPI, the client can set the filtering properties to start/stop filtering TS packets on aparticular TS feed. The API is defined as an abstract interface of the typedmx\_ts\_feed\_t.The functions that implement the interface should be defined static or moduleprivate. The client can get the handle of a TS feed API by calling the functionallocate\_ts\_feed() in the demux API.\kifunction{set()}{ int set ( dmx\_ts\_feed\_t* feed, \_\_u16 pid, size\_t callback\_length, size\_t circular\_buffer\_size, int descramble, struct timespec timeout); }{ This function sets the parameters of a TS feed. Any filtering in progress on the TS feed must be stopped before calling this function. }{ dmx\_ts\_feed\_t* feed & Pointer to the TS feed API and instance data.\\ \_\_u16 pid & PID value to filter. Only the TS packets carrying the specified PID will be passed to the API client.\\ size\_t callback\_length & 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 circular\_buffer\_size & Size of the circular buffer for the filtered TS packets.\\ int descramble & If non-zero, descramble the filtered TS packets.\\ struct timespec timeout & Maximum time to wait before delivering received TS packets to the client. }{ 0 & The function was completed without errors.\\ -ENOMEM & Not enough memory for the requested buffer size.\\ -ENOSYS & No descrambling facility available for TS.\\ -EINVAL & Bad parameter.}\kifunction{start\_filtering()}{ int start\_filtering(dmx\_ts\_feed\_t* feed); }{ 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(). }{ dmx\_ts\_feed\_t* feed & Pointer to the TS feed API and instance data. }{ 0 & The function was completed without errors.\\ -EINVAL & Bad parameter.}\kifunction{stop\_filtering()}{ int stop\_filtering(dmx\_ts\_feed\_t* feed); }{ Stops filtering TS packets on this TS feed. }{ dmx\_ts\_feed\_t* feed & Pointer to the TS feed API and instance data. }{ 0 & The function was completed without errors.\\ -EINVAL & Bad parameter.}\clearpage\devsubsec{Section Feed API}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 moduleprivate. The client can get the handle of a section feed API by calling the functionallocate\_section\_feed() in the demux API.On demux platforms that provide section filtering in hardware, the Section Feed APIimplementation provides a software wrapper for the demux hardware. Other platformsmay support only PID filtering in hardware, requiring that TS packets are converted tosections in software. In the latter case the Section Feed API implementation can be aclient of the TS Feed API.\kifunction{set()}{ int set(dmx\_section\_feed\_t* feed, \_\_u16 pid, size\_t circular\_buffer\_size, int descramble, int check\_crc); }{ 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, only the payloads of private sections can be scrambled while the rest of the section data must be sent in the clear. }{ dmx\_section\_feed\_t* feed & Pointer to the section feed API and instance data.\\ \_\_u16 pid & PID value to filter; only the TS packets carrying the specified PID will be accepted.\\ size\_t circular\_buffer\_size & Size of the circular buffer for filtered sections.\\ int descramble & If non-zero, descramble any sections that are scrambled.\\ int check\_crc & If non-zero, check the CRC values of filtered sections. }{ 0 & The function was completed without errors.\\ -ENOMEM & Not enough memory for the requested buffer size.\\ -ENOSYS & No descrambling facility available for sections.\\ -EINVAL & Bad parameters.}\kifunction{allocate\_filter()}{ int allocate\_filter(dmx\_section\_feed\_t* feed, dmx\_section\_filter\_t** filter); }{ 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 in section \ref{sectionfilter} for the format of the section filter. \\ 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 -- thus this field is ignored, even though it is included in filter\_value and filter\_mask fields. }{ dmx\_section\_feed\_t* feed & Pointer to the section feed API and instance data.\\ dmx\_section\_filter\_t** filter & Pointer to the allocated filter. }{ 0 & The function was completed without errors.\\ -ENOSPC & No filters of given type and length available.\\ -EINVAL & Bad parameters.}\kifunction{release\_filter()}{ int release\_filter ( dmx\_section\_feed\_t* feed, dmx\_section\_filter\_t* filter); }{ 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. }{ dmx\_section\_feed\_t* feed & Pointer to the section feed API and instance data.\\ dmx\_section\_filter\_t* filter & I/O Pointer to the instance data of a section filter. }{ 0 & The function was completed without errors.\\ -ENODEV & No such filter allocated.\\ -EINVAL & Bad parameter.}\kifunction{start\_filtering()}{ int start\_filtering ( dmx\_section\_feed\_t* feed ); }{ 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(). }{ dmx\_section\_feed\_t* feed & Pointer to the section feed API and instance data.\\ }{ 0 & The function was completed without errors.\\ -EINVAL & Bad parameter.}\kifunction{stop\_filtering()}{ int stop\_filtering ( dmx\_section\_feed\_t* feed ); }{ 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. }{ dmx\_section\_feed\_t* feed & Pointer to the section feed API and instance data. }{ 0 & The function was completed without errors.\\ -EINVAL & Bad parameter.}%%% Local Variables: %%% mode: latex%%% TeX-master: "dvbapi"%%% End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -