Summary of the invention
In order to solve above-mentioned technical problem, a kind of stream medium data switching method and device are provided, its purpose is, give full play to the co-operating characteristic of peer network node, the gap of the playback duration by sacrificing data fragmentation transmission time and data fragmentation, exchange reducing of parallel data transmission time between multinode for, thereby guarantee the playback that links up of node stream medium data; Improve the adaptive ability that metadata cache changes the network bandwidth, thereby improve the exchanges data efficient of stream media system terminal.
The invention provides a kind of stream medium data switching method, comprising:
Step 1, user node is set up sliding window;
Step 2 according to the data fragmentation advertising message of each neighbor node, distributes the stream medium data burst downloading task that belongs in the sliding window to give one or more neighbor nodes;
Step 3, the data fit preset condition in sliding window, user node submit to data in the sliding window to stream medium data decoding and playback module to play;
Step 4, the described sliding window that slides, repeated execution of steps 2-step 3 is downloaded until stream medium data and to be finished or user node stops the data exchange process of Streaming Media.
Before step 1, also comprise:
Step 5, user node distribute the stream medium data burst downloading task that belongs in the initialization buffering area to give one or more neighbor nodes according to the data fragmentation advertising message of each neighbor node;
Step 6, after the initialization buffering area is filled, user node submit to data in the buffering area to stream medium data decoding and playback module to play.
Sliding window comprises several basic windows, and each basic window comprises the required space of one or more data slice.
Described preset condition is that the partly or entirely basic window in the sliding window is filled.
The initial border of sliding window is the termination border in the initialization buffering area.
In the step 1, user node is also periodically adjusted the size of sliding window according to network availability bandwidth.
User node is also periodically given neighbor node with the data fragmentation information broadcast of this locality storage, to make things convenient for neighbor node data dispatching burst downloading task.
Data downloaded burst quantity surpasses preset threshold in basic window, and arrives the expectation submission time of this basic window, and the data fragmentation in then will this basic window is submitted to stream medium data and decoded and playback module.
Data fragmentation has the form and the size of regulation, and has the data fragmentation sign of distributing in turn according to the time sequencing of data fragmentation generation.
The invention provides a kind of stream medium data switch, comprising:
The streaming media data cache module is used for setting up sliding window for user node; Data fit preset condition in sliding window, for user node submit to data in the sliding window to stream medium data decoding and playback module playing, and the described sliding window that slides;
Neighbours' administration module is used for the maintenance of neighbor node listing;
Stream medium data decoding and playback module are used to decode and stream medium data that playback stream media data cache module provides
Data transmission module is used for the data fragmentation advertising message according to each neighbor node, distributes the stream medium data burst downloading task that belongs in the sliding window to give one or more neighbor nodes.
Data transmission module also is used for for the data fragmentation advertising message of user node according to each neighbor node, distributes the stream medium data burst downloading task that belongs in the initialization buffering area to give one or more neighbor nodes;
The streaming media data cache module also is used for after the initialization buffering area is filled, for user node submit to data in the buffering area to stream medium data decoding and playback module to play.
Sliding window comprises several basic windows, and each basic window comprises the required space of one or more data slice.
Described preset condition is that the partly or entirely basic window in the sliding window is filled.
The initial border of sliding window is the termination border in the initialization buffering area.
The streaming media data cache module also is used for supplying user node periodically to adjust the size of sliding window according to network availability bandwidth.
Data transmission module also is used for periodically giving neighbor node with the data fragmentation information broadcast of this locality storage for user node, to make things convenient for neighbor node data dispatching burst downloading task.
The streaming media data cache module also is used for surpassing preset threshold when basic window data downloaded burst quantity, and arrives the expectation submission time of this basic window, and the data fragmentation in this basic window is submitted to stream medium data decoding and playback module.
Data fragmentation has the form and the size of regulation, and has the data fragmentation sign of distributing in turn according to the time sequencing of data fragmentation generation.
The present invention provides a kind of exchanges data scheduling mechanism for the exchange of the stream medium data under the P2P environment, can consider the stability of stream media playback, the playback time delay of stream medium data, the variation of network bandwidth resources simultaneously, for the stream medium data exchange provides data fragmentation download schedule method efficiently, improve the playback quality of stream media terminal, improve terminal use's satisfaction.The present invention uses basic windowing mechanism to describe the metadata cache requirement of stream media playback terminal, use sliding window mechanism to describe the data download capabilities of network bandwidth resources, stream media playback buffer memory and data data downloaded buffer memory are made a distinction processing, the means of sharing of stream medium data can be provided more flexibly.
Embodiment
The present invention will be described below in conjunction with the drawings and specific embodiments.
Need to prove that at first the user node among the present invention refers to the employed stream media terminal node of user that sends the stream medium data download instruction, opens Streaming Media transmission and replayed section; Neighbor node refers to can directly carry out the stream media terminal node of exchanges data with this user node in the tabulation of user node neighbor node.
Fig. 3 shows the metadata cache structure chart of a user node.Metadata cache is the memory space of the temporary stream medium data of having downloaded in the user node.Indicate 1,2 among the figure ... small rectangle Deng numeral is represented the stream medium data burst.Data fragmentation is decomposed into the less data block that is fit to the internet transmission in order to tackle the restriction of network layer host-host protocol to the packet size to stream medium data according to certain rule.In the present invention, the data fragmentation notion is the smallest dimension that stream medium data is cut apart.BW1 among Fig. 3, BW2 are basic window, and the size (size) of basic window is not less than the size of data fragmentation.For example, concerning video stream media, we suppose that the size of a frame of video is 2-4kbytes, and the MTU of Ethernet is limited in bag of 1500bytes usually, and therefore needing this frame of video cutting when actual transmissions is minimum 2-3 data burst; And the size of basic window can be the size of 1 or several frame of video.To be metadata cache submit the smallest dimension of data to stream medium data decoding and playback module with basic window, its description be the requirement of media data coding/decoding and playback mechanism to continuous play stream media data.Can comprise one or more data fragmentations in the basic window.In addition, the notion that has also comprised sliding window SW among Fig. 3.What sliding window was described is the current available Streaming Media transmission bandwidth of described user node, comprises one or more basic windows usually, has just comprised three basic windows of BW1, BW2 and BW3 simultaneously as SW in this example.In addition, also have the notion of initialization cushion space InitBuff among Fig. 3, its effect is to set up the initial stage in the multi-medium data downloading task, data is done the buffering of certain data volume, with the influence of the instability that prevents network, go up the playback quality that guarantees stream medium data largely to user node.
Embodiment one
Below in conjunction with Fig. 1, Fig. 2, Fig. 3 and Fig. 4, to elaborating of proposing among the present invention based on the auxiliary stream medium data switching method of sliding window.
When user node is initiated a multimedia data stream download request, this user node at first distributes an initialization cushion space in spatial cache, data fragmentation according to neighbor node broadcasting has information then, distributes the stream medium data burst downloading task that belongs in the initialization buffering area to give one or more neighbor nodes (step S101).
When the download of the data in the described initialization cushion space was finished, data cache module was submitted to special stream medium data decoding and playback module with the data in the initialization cushion space, begins the playback (step S102) of data after the decoding.Simultaneously, basic window BWi is set up on the termination border of next-door neighbour's initialization cushion space in proper order, and i is a natural number, and the size of basic window can be determined according to the employed encoding and decoding standard of this Streaming Media.Basic window all comprises 3 data bursts in Fig. 3, comprises data fragmentation 6,7 and 8 as basic window BW1.If the coded format of stream medium data at a time changes over other coded systems, demand to continuous play stream media data has had variation, the size that user node can the basic window of corresponding immediately change then, and can not have influence on the efficient of streaming media data cache on the node.
At last, sliding window is set up on the termination border of described user node next-door neighbour initialization cushion space, starts sliding window mechanism the downloading process of stream medium data is dispatched (step 103), and dispatching method as shown in Figure 2 in detail.At first, described user node is determined the termination border (step S201) of sliding window according to the sliding window size parameter, and as in Fig. 3, the size of sliding window is the size of 3 basic windows; The second, described user node uses the method identical with step S101, according to the information of data fragmentation that each neighbor node has, distributes the stream medium data burst downloading task that belongs to described sliding window to give one or more neighbor nodes (step S202); When the basic window on next-door neighbour described sliding window initial border is filled, submit in this basic window data to decode and playback module (step S203) to stream medium data; At this moment, move simultaneously backward with the termination border on the initial border of sliding window, covers and submitted the data representative Streaming Media moment basic window (step S204) afterwards to, and this also is the source of sliding window title; Described user node repeating step S202 downloads and the submission process to the data among the step S204, all downloads up to this stream medium data to finish, and perhaps causes the termination (step S205) of stream medium data exchange process because of other reasons.
Based on the auxiliary stream medium data switching method of sliding window, also have some to further specify for above-mentioned.
(1) having wide range of applications among the present invention based on the auxiliary stream medium data switching method of sliding window.Because the transfer of data of using the notion of data fragmentation, basic window, sliding window to explain the data transmission capabilities of network layer, application layer respectively requires and the quantity of network availability bandwidth, this method for interchanging data can satisfy the demand of multiple transmission of flow media data application system, net cast, order program service as customer end/server mode, the net cast of peer-to-peer network pattern, order program service, and the multi-media network phone etc.
(2) the sliding window reaction is the quantity of user node available network bandwidth, and because the unsteadiness that the internet connects, this amount useable bandwidth is a numerical value that constantly changes.Therefore user node needs the quantity of the current available bandwidth of detecting periodically, and revises the sizes values of sliding window.The size of current sliding window is the size of 3 basic windows among Fig. 3.If user node detects network availability bandwidth increase, just the size that can reset sliding window according to the recruitment of this loan is 4 basic windows even more.In addition, because the transfer of data of Streaming Media has certain real-time requirement, if the available bandwidth of network can't support the data of a basic window to download, then its playback quality just can not reach requirement.
(3) because the data in the sliding window are not to arrive according to time sequencing fully, therefore when the basic window data of the initial boundary that is close to sliding window is filled, if the basic window of other one or more stream medium datas of adjacent time fills up, then can once submit a plurality of basic windows to.For example, sliding window SW comprises basic window BW1, BW2 and BW3. after the data among the BW1 all arrive among Fig. 3, and user node judges that the data among the basic window BW2 of next-door neighbour BW1 also all arrive, but the data of BW3 also arrive fully.Then user node stream medium data that basic window BW1 and BW2 are comprised is submitted to stream medium data decoding and playback module, simultaneously sliding window SW is slided backward two basic windows, that is, make sliding window cover basic window BW3, BW4 and BW5, as shown in Figure 4.
(4) the metadata cache space on the user node is limited, and when the stream medium data of having been downloaded when spatial cache took, user node was used new data and covered and be buffered in the earliest the data download constantly of flow-medium performance in the spatial cache.So not only can the control data buffer memory to the internal memory of user node place main frame and the consumption of hard drive space, the latest data that can also keep this Media Stream simultaneously is to share the neighbor node to this user node.
(5) if among the present invention be used in application scenarios in the peer-to-peer network based on the auxiliary stream medium data switching method of sliding window the time, described user node also needs periodically to broadcast the stream medium data burst information of having downloaded in local cache space to its neighbor node, and provides the related streams media data when neighbor node proposes request of data.
(6) stream medium data is decoded and playback module common fault-tolerance of supporting to a certain degree when decoding, and that is to say that if the data that receive have to a certain degree distortion or loss, decoder possesses the ability of reparation or part repair data.Therefore, when the submission at the latest of a basic window arrived constantly, if still there is the data fragmentation under this window of part to fail to arrive, then metadata cache still can submit to the data in this imperfect basic window to give the Streaming Media decoder.Can utilize existing data resource to greatest extent like this, improve the playback quality of Streaming Media as far as possible.
Embodiment two
Below in conjunction with Fig. 5 and Fig. 6 the stream media node device that proposes among the present invention is provided detailed description.
Provided the main functional modules of described stream media node device 500 among Fig. 5, this node apparatus, can be applied in the multiple internet stream media system such as live, program request based on the auxiliary stream medium data switching method of sliding window by described.This node apparatus comprises following main functional modules:
Data transmission module 504, its major responsibility comprises: neighbours' node information that provides according to neighbours' administration module and the data fragmentation information that provides based on the auxiliary streaming media data cache module of sliding window, and be responsible for the downloading task of distribute data burst and give each neighbor node; Simultaneously, data transmission module also is responsible for monitoring the variation of described user node network bandwidth resources, and it is fed back to described data cache module; At last, data transmission module is responsible for sending and receiving the variety of network data bag, and safeguards that the network of each neighbor node connects.
Neighbours' administration module 502, its major responsibility comprises: under peer to peer environment, be responsible for described user node neighbor node list management and maintenance, delete failure node, the new neighbor node of interpolation; According to the difference of peer-to-peer network type, the management method of neighbours' administration module and means need to adjust to some extent, and as in the peer-to-peer network space of using distributed hash table (DHT), this module need be safeguarded the hash space of certain scale according to protocol requirement.
Stream media playback module 501, its major responsibility comprises: the stream medium data that the data cache module is submitted to is decoded; Simultaneously, be responsible for the streaming medium content behind the broadcast decoder, satisfy stream media node device user's demand.
Based on the auxiliary streaming media data cache module 503 of sliding window, its major responsibility comprises: manage local memory space; Set up the also initialization spatial cache of management flow medium; Set up, manage, remove the basic window in the spatial cache; The management sliding window; For the neighbor node of described user node provides the data fragmentation that has in local cache space tabulation.Mainly comprise following submodule in this data cache module:
Local sub module stored 601, be responsible for the maintenance of the local storage region of described user node, the memory allocation of data fragmentation, and carry out the supervisory instruction that a basic dress mouthful management submodule, sliding window management submodule, data are shared management submodule and initialization management submodule.
Basic window management submodule 602, be responsible for basic window structure structure, maintenance, manage and cancel.This module can determine the size of a basic window, that is what data bursts a basic window should comprise according to the coding standard and the required data volume size of this Media Stream of smooth playback of stream medium data.In a stream medium data downloading process, when changing appears in the coded system of stream medium data, required buffer data size has had variation, basic window management submodule can self adaptation be adjusted, and changes the size of basic window.
Sliding window management submodule 603, structure, the maintenance and management of responsible sliding window.Simultaneously, this submodule cooperates with data transmission module, the current network available bandwidth situation that provides according to data transmission module, periodically adjust the size of sliding window, this adaptive mode not only can maximally utilise bandwidth resources, and can effectively avoid blindly carrying out the excess transfer of data.
Initialization management submodule 604 is responsible for the foundation and the maintenance of the initialization buffering area of transmission of flow media data.It is a pair of contradiction that the data continuity of Streaming Media and internet provide the unsteadiness of service, for the disturbance of avoiding the Internet available bandwidth resources influence as far as possible to stream media playback, in the starting stage that stream medium data is downloaded, user node should be before the playback stream media data that begins to decode, a certain amount of data of buffer memory.Therefore the critical function of initialization management submodule is exactly according to the Internet bandwidth resources data of being grasped, and determines the size of initialization spatial cache, between stream media playback delay and playback stability, finds optimal balance point.
Data are shared management submodule 605, are responsible for the neighbor node of data fragmentations all in the local sub module stored of periodic broadcast to described user node, the shared data burst.If the stream media node device among the present invention is applied in the peer-to-peer network, then this node not only can be from its neighbor node download stream media data, also should share in the local cache existing data fragmentation and give its neighbor node.The described stream media node device of present embodiment adopts the mode of periodic broadcasting to send the local data burst information to its all neighbor nodes.
Those skilled in the art can also carry out various modifications to above content under the condition that does not break away from the definite the spirit and scope of the present invention of claims.Therefore scope of the present invention is not limited in above explanation, but determine by the scope of claims.