A kind of cross-platform real-time communication system method
Technical field
The present invention relates to the technical fields that the data interaction applied in process and code stream store, more particularly to one kind is across flat
The real-time communication system method of platform.
Background technique
Many communication plans all call directly the communication interface of system platform, cause communication efficiency low, while each flat
Platform communication otherness it is very big, most convenient namely utilize network interface, but will cause simultaneously it is systematic waste and not really
Fixed conflict.And the present invention then directly utilizes memory completely, and the data interaction in process is made to use very similar network
Interface, but efficiency is very high, it is easy to operate, while not will cause the systematic wasting of resources and conflict etc..
Meanwhile much the code stream way to manage of companies is very more now, and up to the present according to investigation result, these management
Mode all management methods of none science and means are used, also without code logic, taking out every time must after video code flow
The mode that stb need be used judges just to can know that the information such as the type, size and source of video code flow, readability are non-after determining
Often poor, operating procedure is complicated, inefficient.Present invention is alternatively directed to current security industries to develop one ten to the management of video code flow
The api interface of branch encapsulates, the interface make video code flow use and manage it is more scientific, it is more convenient, it is also more simple
It is single.
Summary of the invention
Memory is directly utilized completely the technical problem to be solved in the present invention is to provide a kind of, not only makes its number in process
According to very similar network interface is used interchangeably, efficiency is very high, and operation is very simple, and not will cause systematic resource
Waste and conflict, meanwhile, a very scientific api interface encapsulation is also had developed, so that video code flow using and managing
It is more scientific, it is more convenient, operate more simple real-time communication system method.The present invention is by the following technical programs
Come what is realized:
A kind of cross-platform real-time communication system method is applied in the data interaction and code stream storage in process,
Steps are as follows for application method:
A: cross-platform real-time communication pool first initializes all channels before process unlatching, needs
A channel is created using a thread, channel has been created when early period, does not just have to create again at this time.
B: after channel creates, data is written during channel is in communication and write a position, wherein write point
It sets and refers to and write o'clock in the position of a circle;It needs to change circle when size one is enclosed when writing a position and writing, number of total coils is big multiplied by every circle
Small is exactly to write the circle total data size that can a little deviate, wherein writes the bias size for a little referring to that write-in data are total, total offset is big
The small position of writing for referring to a circle or more is added up, when write a little write circle total data size when, write a zero and open again
Beginning writes data.
C: when needing to read data from this channel, the position for determining read point is first had to, will be read after reading successfully
The positional shift of point reads the size position of data.
D: inside the data of reading are enclosed two, then at this time relate to change circle, it is vertical after having read a circle data
Read point position zero at this time will be read, then proceedes to start to read in the dead-center position of next circle.
E: the type of reading is imported in the data of step B, C, D, the type of reading is data type, when reading data
The type of reading data may be selected.
F: finally destroying channel, and another channel must be re-created when channel needs to reactivate, is carried out again later
Read-write operation.
Further, when re-creating a new channel, read point and write a little all must return-to-zero.
Further, when reading data and write-in data inside channel, read point position, which should be less than, writes a position, when writing
It in the case that point position is greater than the circle of read point position one, needs to reset read point position when reading data, makes read point position and write point
It sets and is in the same point of same circle above.
Further, when data being written in the channel of step B, when the final stage in write-in data, circle sum
After subtracting the maximum value write a little according to size, it is necessary to retain the size of a circle, the speed of write-in data can be kept up with to guarantee to read data
Degree.
Further, when step C reads data, by judging that read point, the size write a little whether can to lock
Data are read, when read point, which is greater than, to be write, then it represents that the error of read point position needs to relocate;Dian Yiquan is write when read point is less than
When, read point also needs to relocate, to guarantee read point and write that a little correctly write-in can be read on the size of a circle
Data;When read point, which is equal to, to be write, then no new data is represented, other situations are normal read datas;Normally reading number
According to when, in the case that the data of reading appear in not same circle, circle need to be changed immediately, after running through when front ring in order to read
Another part data are taken, finally the data copy of reading is gone out.
Further, step C read data when need outside reset read point, then again the size of read point transmit into
Enter channel to judge, the mode of outside resetting read point, which can allow, read point and to be write a little on the same position.
Further, when reading data type in step E, during reading bit stream data, when knowing readout code
The frame type of stream or when being repositioned onto next frame data, needs first to fill out the frame type code place value of reading in outside
It is come into again after good inside channel, carries out circulation reading again after coming into inside channel, until reading data success, inside channel
When no data, then the type of sign of display no data is returned.
Further, it destroys channel and refers to the size of data that release channel is applied in creation.
Further, the thread creation channel in process, reading data, in the channel write-in data or destruction in channel
It is all to be controlled by thread lock when channel, it is therefore an objective to prevent multiple threads while create the same channel, avoid same
There is secondary creation in channel and the phenomenon that secondary read-write occurs in the same channel, and each moment can only allow a thread to this
Channel is operated, and avoids multiple threads while operation is so as to cause the data corruption inside channel, channel when destroying also only
The channel can be discharged by a thread, after per thread has operated corresponding channel, another thread could be allowed to have operated
The corresponding channel of effect.
The cross-platform real-time communication system method of one kind of the invention, applies the data interaction in process and code stream
In storage, it has the advantage that: data interaction uses very similar network interface in process, efficiency is used very
It is efficiently simple, and not will cause the waste and conflict of systemic resource, meanwhile, ten branches are had developed in code stream management
The encapsulation of api interface, make code stream use and manage it is very scientific, it is easy to use, operate very simple, it is high-efficient.
Detailed description of the invention
The present invention is described in detail by following preferred embodiments and attached drawing for ease of explanation,.
Fig. 1 is the overall structure figure of the cross-platform real-time communication system method of one kind of the invention.
Fig. 2 is that the channel creation of the cross-platform real-time communication system method of one kind of the invention and read-write point operation are shown
It is intended to.
Fig. 3 is the reading data of the cross-platform real-time communication system method of one kind of the invention and the process of write-in data
Schematic diagram.
Fig. 4 is showing for the multithreading operation channel process of the cross-platform real-time communication system method of one kind of the invention
It is intended to.
Fig. 5 is the structural schematic diagram of the circle of the cross-platform real-time communication system method of one kind of the invention.
Specific embodiment
To facilitate the understanding of the present invention, a more comprehensive description of the invention is given in the following sections with reference to the relevant attached drawings.In attached drawing
Give better embodiment of the invention.But the invention can be realized in many different forms, however it is not limited to herein
Described embodiment.On the contrary, the purpose of providing these embodiments is that making to understand more the disclosure
Add thorough and comprehensive.
Unless otherwise defined, all technical and scientific terms used herein and belong to technical field of the invention
The normally understood meaning of technical staff is identical.Term as used herein in the specification of the present invention is intended merely to description tool
The purpose of the embodiment of body, it is not intended that in the limitation present invention.
In the present embodiment, referring to figs. 1 to shown in Fig. 5, the cross-platform real-time communication system method of one kind of the invention,
It applies in the data interaction and code stream storage in process, directly utilizes memory completely, not only hand over its data in process
Very similar network interface mutually is used, efficiency is very high, and operation is very simple, and not will cause the systematic wasting of resources
And conflict, meanwhile, a very scientific api interface encapsulation is also had developed, so that video code flow using and managing more
Science, more convenient, operation is more simple, and steps are as follows for application method:
A: cross-platform real-time communication pool first initializes all channels before process unlatching, needs
A channel is created using a thread, channel has been created when early period, does not just have to create again at this time.
B: after channel creates, data is written during channel is in communication and write a position, wherein write point
It sets and refers to and write o'clock in the position of a circle;It needs to change circle when size one is enclosed when writing a position and writing, number of total coils is big multiplied by every circle
Small is exactly to write the circle total data size that can a little deviate, wherein writes the bias size for a little referring to that write-in data are total, total offset is big
The small position of writing for referring to a circle or more is added up, when write a little write circle total data size when, write a zero and open again
Beginning writes data.
C: when needing to read data from this channel, the position for determining read point is first had to, will be read after reading successfully
The positional shift of point reads the size position of data.
D: inside the data of reading are enclosed two, then at this time relate to change circle, it is vertical after having read a circle data
Read point position zero at this time will be read, then proceedes to start to read in the dead-center position of next circle.
E: the type of reading is imported in the data of step B, C, D, the type of reading is data type, when reading data
The type of reading data may be selected.
F: finally destroying channel, and another channel must be re-created when channel needs to reactivate, is carried out again later
Read-write operation.
In one embodiment, when re-creating a new channel, read point and write a little all must return-to-zero.
In one embodiment, when reading data and write-in data inside channel, read point position, which should be less than, to be write a little
Position needs to reset read point position when reading data, makes read point position in the case where writing a position and enclosing greater than read point position one
It is in the same point of same circle above with a position is write.
In one embodiment, when data being written in the channel of step B, when the final stage in write-in data
When, after circle total data size subtracts the maximum value write a little, it is necessary to retain the size of a circle, a little be greater than circle total data this is because writing
Size will do clearing processing later, that is, recalculate, and will appear when read point is also not up to maximum circle total data size and write a little
It resets and read point does not reach the purpose of clearing also, so to wait read point also to arrive when writing size position a little in the circle of read point one
Up to the position of maximum circle total data size, the speed of write-in data can be kept up with to guarantee to read data.
In one embodiment, it when step C reads data, is locked by judging read point, writing size a little
Whether data can be read, when read point, which is greater than, to be write, then it represents that the error of read point position needs to relocate;When read point is less than
When writing an a little circle, read point also needs to relocate, to guarantee read point and write a little can correctly read on the size of a circle
The data being written out;When read point, which is equal to, to be write, then no new data is represented, other situations are normal read datas;Just
When often reading data, in the case that the data of reading appear in not same circle, circle need to be changed immediately after running through when front ring,
In order to read another part data, finally the data copy of reading is gone out.
In one embodiment, read point is reset outside needing when step C reads data, then again the big of read point
Small to be conveyed into channel to judge, the mode of outside resetting read point, which can allow, read point and to be write a little on the same position.
In one embodiment, when reading data type in step E, during reading bit stream data, when knowing
When road reads the frame type of code stream or to be repositioned onto next frame data, need the frame type code place value by reading first
It is come into inside channel again after outside is filled in, carries out circulation reading again after coming into inside channel, until reading data success, when
Inside channel when no data, then the type of sign of display no data is returned.
In one embodiment, it destroys channel and refers to the size of data that release channel is applied in creation.
In one embodiment, the thread creation channel in process, in channel read data, number is written in the channel
According to or destroy channel when be all to be controlled by thread lock, it is therefore an objective to prevent multiple threads while creating the same channel, keep away
Exempt from the same channel and the phenomenon that secondary creation and appearance secondary read-write of the same channel occur, each moment can only allow one
Thread operates the channel, avoids multiple threads while operation is so as to cause the data corruption inside channel, channel is being broken
Also the channel can only be discharged when ruining by a thread, after per thread has operated corresponding channel, another thread could be allowed
To operate effective corresponding channel.
For the very big problem of video codeword data stream, the present invention is provided with the video code flow of special storage big data, makes
Corresponding video code flow can be put into corresponding channel by it, and any thread can take out from the inside, and the video taken out
Code stream can clearly illustrate situations such as its size, source and type, and every channel all has the specifying information that display generates code stream,
Keep the management of video code flow very scientific, it is very clear, it solves traditional video code flow that takes out every time and has to use stb later
Mode judge determine after just can know that the information such as the type, size and source of video code flow, make it have code logic, it is readable
Property is very strong, simplifies operating procedure, has saved the time, high-efficient, present invention overcomes cause the systematic wasting of resources
And the problem of conflict, the utilization rate of system program stability, validity and system resource is greatly enhanced.
Above-described embodiment, only an example of the present invention, be not for limiting implementation and interest field of the invention,
All technical solutions identical or equivalent with content described in the claims in the present invention should all include in the scope of the present invention.