A kind of on-the-spot order method based on real time flow medium
Technical field
The invention belongs to technical field of computer multimedia, particularly streaming media playing server design technology.
Background technology
Stream media technology is a kind of online play-back technology of rising in recent years.Online broadcast, as the term suggests be exactly to play while downloading, player also need not wait until that multimedia file all downloads to local hard drive and plays later on again, but plays when downloading.Player hews out a buffering area in the internal memory of client; the space of several Mbytes normally; after being arranged in the player pending buffer district, enough data begin the decoding broadcast; this process needs the time in several seconds usually; saved the stand-by period with playing to compare greatly again after having downloaded, and owing to do not download on the hard disk, but directly store in the internal memory; promptly be played the device deletion after playing, therefore digital publishing rights played a protective role.
Stream media system mainly is made up of four parts as shown in Figure 1: compressed encoding server, Play Server, file server, player.Play Server is in core position in stream media system, the quality of its design will directly determine the quality of stream media system performance.The service that Play Server externally provides mainly contains two kinds of file program request and on-the-spot program requests.The source of file program request is an audio-video document, and the source of on-the-spot program request is an encoder server.Because encoder server will carry out the collection compression of real time programme, taken a large amount of cpu resources, therefore can not support the user of Da Rong to insert, this part work will be transferred on the Play Server, directly provide on-the-spot some multicast function to the user by Play Server.
Current Play Server provides on-the-spot order method based on real time flow medium to the user, comprises as shown in Figure 2; The information of user's program request is delivered in the user chain table by user's receiving element, the required audio, video data of user is delivered to by the compressed encoding server in the audio frequency and video buffering area of audio, video data receiving element, delivers to according to the information of the user's program request audio, video data that the user is required then and carries out online broadcast in the user's players.
Above-mentioned Play Server is at the compressed encoding server design of solid size rate, can only start single channel audio, video data forwarding capability, and the number of users of supporting is few.
Summary of the invention
The objective of the invention is for overcoming the weak point of prior art, a kind of on-the-spot order method based on real time flow medium is proposed, the present invention is provided with simultaneously and receives buffering area and intransit buffering district, makes it have the support large-capacity user, and the advantage of multichannel audio-video frequency data forwarding function can be provided.
A kind of on-the-spot order method based on real time flow medium that the present invention proposes may further comprise the steps:
1) n that receives user's order request information is delivered to respectively in the 1-M unit of each user chain table of the code stream of asking;
2) n road audio, video data is delivered in the 1-L unit of each audio, video data reception buffering area simultaneously by the compressed encoding server;
3) receive in the 1-K unit in audio, video data intransit buffering district that audio, video data in the buffering area sends to corresponding code stream respectively;
4) read user in the user chain table of corresponding code stream, give corresponding user with data forwarding in the audio frequency and video intransit buffering district of different code streams, the user appreciates the program of the code stream of asking by player.
The total n road input of the structural design of this method, the code stream of the code stream of the on-the-spot broadcasting program that each road input is corresponding different or the different code checks of same on-the-spot broadcasting program.
The specific implementation method of above-mentioned step 1 can may further comprise the steps:
(1) waits for that the user inserts;
(2) insert as user's program request,, this user profile is put into the user chain table unit 1 of corresponding code stream in unit M according to on-the-spot broadcasting program that the user asked or the code check of being asked;
(3) return the access of waiting for next user then.
The specific implementation method of above-mentioned steps 3 can may further comprise the steps:
(1) data of stand by tone video reception buffer location 1 in the unit L;
(2) if receiving buffer location 1, audio frequency and video in unit L, data are arranged;
(3) unit 1 in audio frequency and video intransit buffering district that audio, video data is put into corresponding code stream in the unit K after, wait for the arrival of next audio, video data;
(4) if audio frequency and video receive buffer location 1 free of data in the unit L, then wait for the arrival of next audio, video data.
The specific implementation method of step 4 can may further comprise the steps:
(1) data in the stand by tone video intransit buffering district;
(2) in the audio frequency and video intransit buffering district audio, video data is arranged, judge in the user chain table of corresponding code stream whether user accessing information is arranged,, return step 1 then if do not throw away this audio, video data;
(3) if user accessing information is arranged, just travel through user chain table unit 1 to unit M, the audio, video data in the audio frequency and video intransit buffering district is transmitted to each user in the user chain table of corresponding code stream;
(4) return the next audio, video data of wait.
Method characteristics of the present invention:
1. can receive a plurality of real time programmes source, or same real time programme source different coding speed;
2. support a large amount of user's program requests to insert;
3. modularized design is adopted in audio frequency and video input and user's program request;
4. clear in structure;
5. reliability height.
Description of drawings
Fig. 1 is typical stream media system structure chart.
Fig. 2 is existing single channel audio, video data forwarding process figure.
Fig. 3 is the on-the-spot order method overview flow chart based on real time flow medium of the present invention.
Fig. 4 is user's method of reseptance detail flowchart of the present invention.
Fig. 5 is an audio, video data method of reseptance detail flowchart of the present invention.
Fig. 6 is an audio, video data retransmission method detail flowchart of the present invention.
Embodiment
The on-the-spot order method embodiment based on real time flow medium that the present invention proposes is described with reference to the accompanying drawings as follows:
A kind of on-the-spot order method overall procedure based on real time flow medium that the present invention proposes as shown in Figure 3, may further comprise the steps:
1) n that receives user's order request information is delivered to respectively in the 1-M unit of each user chain table of the code stream of asking;
2) the road audio, video data is delivered in the 1-L unit of each audio, video data reception buffering area simultaneously by the compressed encoding server;
3) will receive in the 1-K unit in audio, video data intransit buffering district that audio, video data in the buffering area sends to corresponding code stream respectively;
4) read user in the user chain table of corresponding code stream, give corresponding user with data forwarding in the audio frequency and video intransit buffering district of different code streams, the user appreciates the program of the code stream of asking by player.
The total n road input of the structural design of this method, the code stream of the code stream of the on-the-spot broadcasting program that each road input is corresponding different or the different code checks of same on-the-spot broadcasting program.
The specific implementation method of above-mentioned general steps 1 as shown in Figure 4, may further comprise the steps:
(1) waits for that the user inserts;
(2) insert as user's program request,, this user profile is put into the user chain table unit 1 of corresponding code stream in unit M according to on-the-spot broadcasting program that the user asked or the code check of being asked;
(3) return the access of waiting for next user then.
The specific implementation method of above-mentioned general steps 3 as shown in Figure 5, may further comprise the steps:
(1) data of stand by tone video reception buffer location 1 in the unit L;
(2) if receiving buffer location 1, audio frequency and video in unit L, data are arranged;
(3) unit 1 in audio frequency and video intransit buffering district that audio, video data is put into corresponding code stream in the unit K after, wait for the arrival of next audio, video data;
(4) if audio frequency and video receive buffer location 1 free of data in the unit L, then wait for the arrival of next audio, video data.
The specific implementation method of above-mentioned general steps 4 may further comprise the steps as shown in Figure 6:
(1) data in the stand by tone video intransit buffering district;
(2) in the audio frequency and video intransit buffering district audio, video data is arranged, judge in the user chain table of corresponding code stream whether user accessing information is arranged,, return step 1 then if do not throw away this audio, video data;
(3) if user accessing information is arranged, just travel through user chain table unit 1 to unit M, the audio, video data in the audio frequency and video intransit buffering district is transmitted to each user in the user chain table of corresponding code stream;
(4) return the next audio, video data of wait.
The embodiments of the invention implementation method is described in detail as follows in conjunction with shown in Fig. 3,4,5,6, and present embodiment may further comprise the steps:
1. after user's receiving thread starts, wait for that user's program request inserts;
2. insert as the user, according to the code check of code stream that the user asks, user's receiving thread is put into the user chain table of corresponding code stream with this user profile, returns the next user's of wait access then;
3. the audio frequency and video receiving thread receives buffering area reception audio, video data from the audio frequency and video of corresponding code stream, if audio frequency and video receive in the buffering area data are arranged, audio, video data is forwarded in the audio frequency and video intransit buffering district of corresponding code stream, continues to wait for the arrival of next audio, video data then;
4. audio frequency and video are transmitted the audio, video data in the thread stand by tone video intransit buffering district, if in the audio frequency and video intransit buffering district audio, video data is arranged, judge then in the user chain table of corresponding code stream whether the user is arranged, if number of users is greater than 1, just travel through user chain table, the audio, video data in the audio frequency and video intransit buffering district is transmitted to the user; As not having the user in the corresponding code stream user chain table, the audio, video data of receiving is thrown away, return the next audio, video data data in the stand by tone video intransit buffering district then.
Being configured to of the compressed encoding server that present embodiment adopts:
CPU:Intel?PIII?1GHz
Internal memory: 128M
Operating system: RedHat7.1 Linux Server
Programming language: C++
Program source: the different coding speed of the same program of n=3:
rate1=100kbps
rate2=450kbps
rate3=900kbps
Being set to of parameter in the present embodiment:
Maximum user inserts number: 3000
Audio frequency and video receive buffering area L=50
Audio frequency and video intransit buffering district K=50
User chain table M=3000
Audio frequency and video buffering area and user chain table all adopt single-track link table to realize, audio, video data receives, the user inserts, the forwarding of audio, video data all adopts thread to realize.