Section acquisition method based on recording mode
Technical Field
The invention relates to the field of communication, in particular to a Section acquisition method based on a recording mode.
Background
Nowadays, with the rapid development of technology, multimedia technology is also changing day by day, however, DVB (Digital Video Broadcasting, hereinafter referred to as DVB) and related application technologies of Digital Video Broadcasting still have important application scenarios, especially in the aspect of satellite Broadcasting, because the foreign market is open to satellite Broadcasting and some remote areas have limited network services, mobile networks and broadband are not covered, which leads to information obstruction, and the satellite Broadcasting technology is a relatively effective solution.
In the related technology of DVB, after received data is modulated and demodulated, channel decoded, source decoded and demultiplexed, descrambling and the like are certainly required to be performed on the encrypted data, and then a TS (Transport Stream, hereinafter referred to as TS) data Stream sent by a satellite is taken to acquire related data such as related frequency point data, audio and video of a program, EPG and the like, and then playing and related display can be realized.
Generally, data such as audio and video are obtained by filtering PID (Packet identifier, PID) corresponding to a DEMUX (Demultiplexer, DEMUX) and are obtained, if a part of platform filters some PID related data from a plurality of DEMUXs, all the PID related data are collected into one thread to be processed, but the PID related data cannot be separated, at this time, if the data volume is too large, the processing of the related data of each PID causes some operations such as time consumption, and the like, so that the data of a part of PID is finally taken, and especially, in the obtaining of data of some Section (data corresponding to data tables such as various PIDs such as audio and video, and are referred to as Section hereinafter), it is important that some desired effects are difficult to achieve if the data are missing.
To solve this problem, we can use recording mode, and usually the recording is to filter the acquired data with part of PID, and process it separately on DEMUX, so as to avoid the above mentioned situation.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a Section acquisition method implemented based on a recording manner, aiming at the above-mentioned defects in the prior art.
The technical scheme adopted by the invention for solving the technical problems is as follows: a Section acquisition method based on a recording mode is constructed, and the method comprises the following steps:
initializing recording, acquiring an input source bound by the DEMUX, and creating a recording channel handle;
if the record channel handle is successfully created, the callback of the channel handle is registered, a message queue pool is created, and an input port corresponding to the DEMUX is set;
creating a DEMUX recording channel corresponding to the handle;
if the recording channel is successfully established, adding PID data to be recorded;
starting a recording channel, starting a recording thread and a stream pushing thread, and starting recording;
when data are recorded, TS data of a current recording channel obtained from the DEMUX are obtained in the recording thread;
acquiring TS data from a message queue pool in a plug flow thread;
and calling back the relevant recorded data and taking the Section data corresponding to the PID.
Preferably, in the step, when data is recorded, the recording thread acquires TS data acquired from the DEMUX in the TS data of the current channel, inserts the acquired TS data into the message queue pool, and acquires the inserted TS from the message queue pool by using the stream pushing thread.
Preferably, the recording data related to the step is called back, and is taken into the Section data corresponding to the PID, and the Section data corresponding to the PID is taken through a group package and a group Section.
Preferably, when the DEMUX recording channel corresponding to the handle is created, if the creation fails, the recording is ended or the initial recording is returned.
Preferably, the method records TS packets of a single PID or a plurality of PIDs.
The Section acquisition method based on the recording mode has the following beneficial effects: and recording TS packets of a single PID or a plurality of PIDs through the DEMUX, pushing streams through the message queue, putting TS data in a message queue pool, acquiring data in the message queue pool by another thread, and acquiring Section data through a group data packet algorithm to acquire the corresponding Section data on one or a plurality of PIDs.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
fig. 1 is a schematic flow chart of a section obtaining method implemented based on a recording mode in an embodiment of the present invention.
Detailed Description
For a more clear understanding of the technical features, objects and effects of the present invention, embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
As shown in fig. 1, a section acquiring method implemented based on a recording manner in a preferred embodiment of the present invention includes the following steps:
initializing recording, acquiring an input source bound by the DEMUX, and creating a recording channel handle;
registering callback of the channel handle if the recorded channel handle is successfully created, creating a message queue pool, and setting an input port corresponding to the DEMUX;
creating a DEMUX recording channel corresponding to the handle;
if the recording channel is successfully established, adding PID data to be recorded;
starting a recording channel, starting a recording thread and a stream pushing thread, and starting recording;
when data are recorded, TS data of a current recording channel obtained from the DEMUX are obtained in the recording thread;
acquiring TS data from a message queue pool in a plug flow thread;
and calling back the related recorded data and taking the Section data corresponding to the PID.
According to the scheme, TS packets of a single PID or a plurality of PIDs are recorded through the DEMUX, then stream pushing is carried out through the message queue, TS data are placed in a message queue pool, then another thread obtains data in the message queue pool through a group data packet algorithm, and then Section data are obtained through a group data packet algorithm, and Section data corresponding to one or a plurality of PIDs are obtained.
When data are recorded, the recording thread acquires TS data acquired from a DEMUX (digital multiplexer) to a current channel, the acquired TS data are inserted into a message queue pool, and a stream pushing thread is used for acquiring the inserted TS from the message queue pool.
And calling back related recorded data, taking the recorded data into the Section data corresponding to the PID, and taking the Section data corresponding to the PID through the group package and the Section group.
And when the DEMUX recording channel corresponding to the handle is created, if the creation fails, ending or returning to the initial recording.
The scheme aims to solve the problem that Section data of some PIDs can be effectively acquired in DVB data stream acquisition, and avoids the problem that data is processed in one thread because all DEMUX filters data of the PIDs on a part of platforms, and if the data is not processed, data leakage is caused, and a recording stream pushing mode is adopted, so that the situation can be solved.
It is to be understood that the above-described respective technical features may be used in any combination without limitation.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes performed by the present specification and drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.