CN108540448B - Streaming media data sending method - Google Patents
Streaming media data sending method Download PDFInfo
- Publication number
- CN108540448B CN108540448B CN201810179822.9A CN201810179822A CN108540448B CN 108540448 B CN108540448 B CN 108540448B CN 201810179822 A CN201810179822 A CN 201810179822A CN 108540448 B CN108540448 B CN 108540448B
- Authority
- CN
- China
- Prior art keywords
- sending
- streaming media
- writing
- data
- media data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 40
- 239000000872 buffer Substances 0.000 claims abstract description 80
- 230000005540 biological transmission Effects 0.000 claims description 39
- 230000004044 response Effects 0.000 abstract description 4
- 238000004891 communication Methods 0.000 abstract description 3
- 230000009286 beneficial effect Effects 0.000 abstract description 2
- 238000005516 engineering process Methods 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 3
- 238000004519 manufacturing process Methods 0.000 description 3
- 230000007717 exclusion Effects 0.000 description 2
- 241000135164 Timea Species 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/60—Network streaming of media packets
- H04L65/75—Media network packet handling
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/60—Network streaming of media packets
- H04L65/65—Network streaming protocols, e.g. real-time transport protocol [RTP] or real-time control protocol [RTCP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
- H04N21/433—Content storage operation, e.g. storage operation in response to a pause request, caching operations
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Computer Networks & Wireless Communication (AREA)
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Communication Control (AREA)
Abstract
The invention discloses a streaming media data sending method, which belongs to the technology in the field of image communication and comprises the following steps: step S1, using the current writing position of the streaming media data as the sending position for sending operation; step S2, comparing the sending position and the writing position: if the writing position is larger than the sending position and the distance between the sending position and the writing position is smaller than or equal to the preset length of the sliding window, carrying out the sending operation; otherwise, the sending operation is aborted. The technical scheme has the beneficial effects that: the invention calculates the Q value of the sending position before sending by setting a plurality of independent buffers, and directly judges whether to carry out sending operation according to the Q value, thereby improving the response speed and reducing the expenditure of system resources.
Description
Technical Field
The invention relates to a technology in the field of image communication, in particular to a streaming media data sending method.
Background
The network camera is a special device for acquiring external data and is an important component in the field of security protection at present. The function of network transmission is provided while capturing images, so how to organize, store and forward streaming media data becomes a problem that must be faced. What this service needs to solve is a very obvious producer-consumer problem, the producer of the streaming media data is responsible for writing the generated data into the buffer, the network sending module is responsible for taking the data away and sending the data as the consumer of the media data, but the inconsistency of speed and state between production and consumption aggravates the complexity of problem processing.
The following processing modes are generally adopted in the production consumption model of the code stream: the status of the ring buffer is recorded by a number of "control information blocks". The annular frame buffer is organized by adopting a mutual exclusion access means provided by the system so as to achieve the production and consumption of frame data. The 'control information block' is a medium for communication between a plurality of producers and a plurality of consumers, the access problem is usually solved by adopting a process and thread synchronization method, the commonly used method comprises mutual exclusion lock, semaphore and the like, and if the solution method is not perfect, the waste of computing resources and even the deadlock condition are easy to occur.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a streaming media data sending method. The invention improves the data processing capacity by arranging a plurality of independent buffer areas, calculates the Q value of the sending position before sending, and directly judges whether to carry out sending operation according to the Q value, thereby improving the response speed and reducing the expenditure of system resources.
The invention is realized by the following technical scheme:
the invention relates to a streaming media data sending method, which is applied to a network camera.A plurality of buffer areas are preset in a memory of the network camera, and each buffer area is an annular buffer area connected end to end;
a sliding window with a preset length is arranged in the buffer area;
each buffer independently performs a transmission process of streaming media data, the transmission process including:
step S1, using the current writing position of the streaming media data as the sending position for sending operation;
step S2, comparing the sending position with the writing position:
if the writing position is larger than the sending position and the distance between the sending position and the writing position is smaller than or equal to the preset length of the sliding window, carrying out the sending operation;
otherwise, the sending operation is aborted.
Preferably, in the streaming media data transmission method, in step S2, the distance between the sending position and the writing position is characterized by the Q value at the sending position to be smaller than the preset length of the sliding window:
if the Q value is greater than or equal to 0, the distance between the sending position and the writing position is less than or equal to the preset length of the sliding window;
if the Q value is smaller than 0, the distance between the sending position and the writing position is larger than the preset length of the sliding window.
Preferably, the streaming media data transmission method, wherein the calculation formula of the Q value is as follows: q ═ ((X + l) modL) -Y, where: x is the sending position, Y is the writing position, L is the preset length of the sliding window, and L is the length of the buffer area.
Preferably, the streaming media data transmission method, wherein the streaming media data is encapsulated in a plurality of data packets having a preset format, and the preset format includes: the system comprises a protocol header, an information header of the streaming media data and a data segment for storing the streaming media data.
Preferably, the streaming media data sending method, wherein the streaming media data in each buffer area is written through an independent writing process, and the writing process includes:
step a1, writing the streaming media data in the writing position of the buffer area;
step a2, taking the capacity between the writing position and the tail end of the buffer as the remaining space, and comparing the remaining space with the size of the data packet:
if the residual space is not enough to store the protocol packet header of the data packet, writing the data packet into the head of the buffer area;
if the residual space is not enough for storing the data packet and is enough for storing the protocol packet header, writing the protocol packet header of the data packet in the residual space, and writing the rest of the data packet from the head of the buffer area;
and if the residual space is enough to store the data packet, continuing to write the data packet.
Preferably, the streaming media data transmission method, wherein the streaming media data includes audio data and video data.
Preferably, the streaming media data transmission method, wherein the writing operation of the audio data and the writing operation of the video data are mutually exclusive.
Preferably, the streaming media data transmission method, wherein each timeA size of the buffer area is 2nBit, wherein n is an integer greater than zero.
Preferably, the streaming media data transmission method, wherein the buffer areas include a first buffer area with a size of 8MB, a second buffer area with a size of 4MB, and a third buffer area with a size of 4 MB.
The beneficial effects of the above technical scheme are:
the invention improves the processing capacity of data by arranging a plurality of independent buffer areas, calculates the Q value of the sending position before sending, and directly judges whether to carry out sending operation according to the Q value, thereby improving the response speed and reducing the expenditure of system resources.
Drawings
Fig. 1 is a flow chart illustrating a method for transmitting streaming media data according to a preferred embodiment of the present invention;
FIG. 2 is a diagram illustrating a buffer structure of a streaming media data transmission method according to a preferred embodiment of the present invention;
fig. 3 is a schematic diagram illustrating a position of a sliding window of a streaming media data transmission method according to a preferred embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a plurality of sending operation processes of a streaming media data sending method according to a preferred embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
The invention is further described with reference to the following drawings and specific examples, which are not intended to be limiting.
The embodiment relates to a streaming media data transmission method, which is suitable for transmission of data generated by a network camera, wherein the network camera needs to transmit the generated data in a streaming media form through a network.
The streaming media data is encapsulated in a plurality of data packets with preset formats, and the preset formats comprise: the system comprises a protocol header, an information header of the streaming media data and a data segment for storing the streaming media data.
The streaming media data of (1) includes audio data and video data.
As shown in fig. 1, in this embodiment, a plurality of buffer areas are preset in a memory of a network camera, and each buffer area is an annular buffer area connected end to end;
a sliding window with a preset length is arranged in the buffer area;
each buffer zone independently executes the transmission process of the streaming media data, and the transmission process comprises the following steps:
step S1, using the current writing position of the stream media data as the sending position for sending operation;
step S2, comparing the sending position and the writing position:
if the writing position is larger than the sending position and the distance between the sending position and the writing position is smaller than or equal to the preset length of the sliding window, sending operation is carried out;
otherwise, the sending operation is aborted.
In step S2, the distance between the sending position and the writing position is characterized by the Q value at the sending position being less than the preset length of the sliding window:
if the Q value is greater than or equal to 0, the distance between the sending position and the writing position is less than or equal to the preset length of the sliding window;
and if the Q value is less than 0, the distance between the sending position and the writing position is greater than the preset length of the sliding window.
The streaming media data in each buffer area is written by an independent writing process, and the writing process comprises the following steps:
step A1, writing streaming media data at the writing position of the buffer;
step a2, taking the capacity between the writing position and the tail end of the buffer as the remaining space, comparing the remaining space with the size of the data packet:
if the residual space is not enough to store the protocol packet head of the data packet, the data packet is written in the head of the buffer area;
if the residual space is not enough to store the data packet and is enough to store the protocol header, writing the protocol header of the data packet in the residual space, and writing the rest part of the data packet from the head of the buffer area;
if the remaining space is enough to store the data packet, the data packet is continuously written.
As shown in fig. 2, in this embodiment, a plurality of strip-shaped buffer areas are preset in the memory, and stream media data generated by a producer is temporarily stored in the buffer areas.
Each buffer is a shared area, which facilitates access to the buffer by other processes.
Each buffer has a size of 2nBit, wherein n is an integer greater than zero.
In each buffer area, firstly, the writing operation of the streaming media data is carried out to form a written data stream, and then the sending operation is carried out at a plurality of sending positions of the storage area of the streaming media data to form a plurality of independent sending data streams.
The video data and the audio data in the streaming media data need to be written in the buffer area, and the audio writing thread and the video data writing thread are mutually exclusive. The writing position of the streaming media data is the position pointed by the writing pointer. And the audio data write thread and the video data write thread respectively perform write operation at the buffer area pointed by the write pointer.
Each buffer can perform write operations as well as send operations, and multiple threads can perform send operations simultaneously in the same buffer. And different sending threads in the same buffer carry out sending operation at the corresponding sending position, namely the position pointed by the sending pointer.
Thus, in each buffer there is one write data stream and multiple transmit data streams. The write thread takes the position pointed by the write pointer as a write position. Each send thread sends data written to the buffer, forming multiple independent send data streams.
All video data and audio data generated by the network camera are buffered through each buffer area, a plurality of sending threads are arranged in each buffer area to form sending data streams, and the video data and the audio data generated by the camera are sent out.
In the preferred embodiment, the buffers include a first buffer of 8MB, a second buffer of 4MB and a third buffer of 4 MB.
As shown in fig. 3, a sliding window is provided in each buffer, by which the distance between the producer and consumer, i.e. the respective sending and writing position, is controlled. The sliding window is used for preventing a certain data stream in the buffer area from sending data too slowly, so that excessive data backlog is caused.
When the data between the sending position and the writing position is excessive, the writing position may perform a writing operation at a position where the unsent data exists, thereby overwriting the original data.
In each transmission data stream, before each transmission operation, a Q value at a transmission position is obtained:
if the Q value is greater than or equal to 0, carrying out the sending operation of sending the data stream;
if the Q value is less than 0, the sending operation of the sending data stream is stopped.
The Q value is calculated by the formula:
Q=((X+l)modL)-Y;
wherein: x is the sending position of the sending data stream;
y is a writing position;
l is a preset length of a sliding window arranged in each buffer area;
l is the length of the buffer.
When the Q value is less than 0, it indicates that the sending data of the sending data stream is too slow, i.e. the distance between the sending position where the sending operation is performed and the writing position where the writing operation is performed is too large, which results in data backlog between the sending position and the writing position. In this case, it is necessary to perform a transmission operation for terminating the transmission data stream.
After the transmission data stream is terminated, the transmission position may be advanced, that is, a data segment with a certain size is skipped, so that the Q value of the transmission position of the transmission data stream is greater than or equal to 0.
After the transmission data flow is stopped, an interval transmission strategy can also be adopted, namely, a transmission pointer skips over a partial area in the buffer area to realize interval data transmission, so that the transmission speed of the whole transmission data flow is improved.
After the transmission data flow is stopped, the thread for carrying out the transmission operation can be reset, thereby solving the problem of too slow transmission.
If the remaining space at the tail part of the buffer area is smaller than the data packet, comparing the protocol packet head of the data packet with the remaining space:
if the residual space is smaller than the data packet, the data packet is written in the head of the buffer area;
and if the residual space is larger than or equal to the data packet, writing the protocol header of the data packet in the residual space, and writing the rest part of the data packet from the head of the buffer area.
Correspondingly, if the protocol header of the data packet exists in the remaining space, the sending pointer corresponding to the sending data stream points to the position where the protocol header exists, and the data packet header is sent. Otherwise, the sending pointer of the sending data stream jumps to the initial position of the head of the buffer area to carry out sending operation.
As shown in fig. 4, the buffer in the figure has three sending positions, that is, three sending threads send data simultaneously.
And Q at the sending position in the sliding window is greater than or equal to 0, the data is not backlogged, the sending operation is continued to the position, and the streaming media data is sent through the formed sending data stream. And Q at the sending position outside the sliding window is less than 0, and the sending is stopped if the data is overstocked, and the sending thread is stopped.
Compared with the prior art, the streaming media data sending method of the invention comprises the following steps:
the invention improves the processing capacity of data by arranging a plurality of independent buffer areas, calculates the Q value of the sending position before sending, and directly judges whether to carry out sending operation according to the Q value, thereby improving the response speed and reducing the expenditure of system resources.
While the invention has been described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention.
Claims (8)
1. A method for transmitting streaming media data, which is applied to a network camera, is characterized in that,
presetting a plurality of buffer areas in a memory of the network camera, wherein each buffer area is an annular buffer area connected end to end;
a sliding window with a preset length is arranged in the buffer area;
each buffer independently performs a transmission process of streaming media data, the transmission process including:
step S1, using the current writing position of the streaming media data as the sending position for sending operation;
step S2, comparing the sending position and the writing position:
if the writing position is larger than the sending position and the distance between the sending position and the writing position is smaller than or equal to the preset length of the sliding window, carrying out the sending operation;
otherwise, stopping the sending operation;
in step S2, the distance between the sending position and the writing position is characterized by a Q value at the sending position being smaller than the preset length of the sliding window:
if the Q value is greater than or equal to 0, the distance between the sending position and the writing position is less than or equal to the preset length of the sliding window;
if the Q value is smaller than 0, the distance between the sending position and the writing position is larger than the preset length of the sliding window;
and the same buffer area is provided with a plurality of sending threads for sending operation at the same time, and different sending threads carry out sending operation at the corresponding sending positions.
2. The streaming media data transmission method according to claim 1,
the Q value is calculated by the formula: q ═ ((X + l) modL) -Y, where: x is the sending position, Y is the writing position, L is the preset length of the sliding window, and L is the length of the buffer area.
3. The streaming media data transmission method according to claim 1,
the streaming media data is encapsulated in a plurality of data packets with preset formats, and the preset formats include: the system comprises a protocol header, an information header of the streaming media data and a data segment for storing the streaming media data.
4. The streaming media data transmission method according to claim 3,
the streaming media data in each buffer area is written by an independent writing process, and the writing process comprises the following steps:
step a1, writing the streaming media data in the writing position of the buffer area;
step a2, taking the capacity between the writing position and the tail end of the buffer as the remaining space, and comparing the remaining space with the size of the data packet:
if the residual space is not enough to store the protocol packet header of the data packet, writing the data packet into the head of the buffer area;
if the residual space is not enough for storing the data packet and is enough for storing the protocol packet header, writing the protocol packet header of the data packet in the residual space, and writing the rest of the data packet from the head of the buffer area;
and if the residual space is enough to store the data packet, continuing to write the data packet.
5. The method for transmitting streaming media data according to claim 1, wherein the streaming media data comprises audio data and video data.
6. The method for transmitting streaming media data according to claim 5, wherein the writing operation of the audio data and the writing operation of the video data are mutually exclusive.
7. The method for transmitting streaming media data according to claim 1, wherein the size of each buffer is 2nBit, wherein n is an integer greater than zero.
8. The method for transmitting streaming media data according to claim 1, wherein the buffers comprise a first buffer with a size of 8MB, a second buffer with a size of 4MB, and a third buffer with a size of 4 MB.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810179822.9A CN108540448B (en) | 2018-03-05 | 2018-03-05 | Streaming media data sending method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810179822.9A CN108540448B (en) | 2018-03-05 | 2018-03-05 | Streaming media data sending method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108540448A CN108540448A (en) | 2018-09-14 |
CN108540448B true CN108540448B (en) | 2021-08-13 |
Family
ID=63486594
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810179822.9A Active CN108540448B (en) | 2018-03-05 | 2018-03-05 | Streaming media data sending method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108540448B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106559706A (en) * | 2015-09-28 | 2017-04-05 | 青岛海信电器股份有限公司 | A kind of processing method of voice data, device and system |
CN106604055A (en) * | 2017-01-06 | 2017-04-26 | 广州四三九九信息科技有限公司 | Video smooth transmission and live broadcasting uplink method based on complex weak mobile network environment |
CN106598696A (en) * | 2016-11-08 | 2017-04-26 | 北京华为数字技术有限公司 | Data interaction method and apparatus for virtual machines |
CN107293316A (en) * | 2016-04-13 | 2017-10-24 | 青岛海信电器股份有限公司 | A kind of audio data processing method and device |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9949027B2 (en) * | 2016-03-31 | 2018-04-17 | Qualcomm Incorporated | Systems and methods for handling silence in audio streams |
-
2018
- 2018-03-05 CN CN201810179822.9A patent/CN108540448B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106559706A (en) * | 2015-09-28 | 2017-04-05 | 青岛海信电器股份有限公司 | A kind of processing method of voice data, device and system |
CN107293316A (en) * | 2016-04-13 | 2017-10-24 | 青岛海信电器股份有限公司 | A kind of audio data processing method and device |
CN106598696A (en) * | 2016-11-08 | 2017-04-26 | 北京华为数字技术有限公司 | Data interaction method and apparatus for virtual machines |
CN106604055A (en) * | 2017-01-06 | 2017-04-26 | 广州四三九九信息科技有限公司 | Video smooth transmission and live broadcasting uplink method based on complex weak mobile network environment |
Non-Patent Citations (1)
Title |
---|
一种与缓冲区紧耦合的环形循环滑动窗口的数据流抽取算法;詹英等;《电子学报》;20110430;第1-5页 * |
Also Published As
Publication number | Publication date |
---|---|
CN108540448A (en) | 2018-09-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9973728B2 (en) | System and method for supporting selective backtracking data recording | |
JP3633884B2 (en) | Playback image transmission device | |
CN100484213C (en) | More user friendly time-shift buffer | |
JP3535297B2 (en) | Image data decoding method and image data decoding device using this method | |
CN103237208A (en) | High-definition video output method based on FPGA (field programmable gate array) | |
CN113132552B (en) | Video stream processing method and device | |
CN101895736B (en) | Media stream data processing method and device thereof | |
CN108540448B (en) | Streaming media data sending method | |
CN107430496A (en) | Frame is abandoned for long-range display | |
CN102625086B (en) | DDR2 (Double Data Rate 2) storage method and system for high-definition digital matrix | |
CN103036808A (en) | Method and system for removing network jitter | |
CN110636219B (en) | Video data stream transmission method and device | |
JPH1198099A (en) | Method and device for multiplexing data | |
CN103391415A (en) | Video data frame loss processing method and system | |
CN111757034A (en) | FPGA-based video synchronous display method and device and storage medium | |
CN205385561U (en) | Tiled display systems of shielding more | |
CN213069802U (en) | Non-homologous clock data transmission system | |
CN114374875A (en) | MP4 file recording method and device and readable storage medium | |
US20160150270A1 (en) | Storing method and Processing Device Thereof | |
CN112203050A (en) | Method and device for continuously transmitting video | |
CN105744120A (en) | High speed data collection card and data collection method | |
JP2001268134A (en) | Network transmitter | |
CN106899880A (en) | The method and system that multi-medium data segmentation is preserved | |
CN102655604B (en) | Method for processing video frequency and equipment | |
CN111654886A (en) | Method and device for limiting user bandwidth |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
PE01 | Entry into force of the registration of the contract for pledge of patent right |
Denomination of invention: A Streaming Media Data Transmission Method Granted publication date: 20210813 Pledgee: Industrial Bank Co.,Ltd. Shanghai Dahua sub branch Pledgor: SHANGHAI DIVEO ELECTRONIC EQUIPMENT CO.,LTD. Registration number: Y2024310000139 |
|
PE01 | Entry into force of the registration of the contract for pledge of patent right |