WO2020216277A1 - 一种媒体流发送方法、装置、设备和系统 - Google Patents

一种媒体流发送方法、装置、设备和系统 Download PDF

Info

Publication number
WO2020216277A1
WO2020216277A1 PCT/CN2020/086335 CN2020086335W WO2020216277A1 WO 2020216277 A1 WO2020216277 A1 WO 2020216277A1 CN 2020086335 W CN2020086335 W CN 2020086335W WO 2020216277 A1 WO2020216277 A1 WO 2020216277A1
Authority
WO
WIPO (PCT)
Prior art keywords
client
live
media stream
proxy
request message
Prior art date
Application number
PCT/CN2020/086335
Other languages
English (en)
French (fr)
Inventor
乔乃强
周军
张明礼
开毅
Original Assignee
华为技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to KR1020217021677A priority Critical patent/KR102457526B1/ko
Priority to JP2021542510A priority patent/JP7259056B2/ja
Priority to EP20796076.6A priority patent/EP3890265B1/en
Publication of WO2020216277A1 publication Critical patent/WO2020216277A1/zh
Priority to US17/369,580 priority patent/US11330028B2/en
Priority to US17/675,236 priority patent/US11848973B2/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/61Network streaming of media packets for supporting one-way streaming services, e.g. Internet radio
    • H04L65/611Network streaming of media packets for supporting one-way streaming services, e.g. Internet radio for multicast or broadcast
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/21Server components or server architectures
    • H04N21/222Secondary servers, e.g. proxy server, cable television Head-end
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/10Architectures or entities
    • H04L65/1045Proxies, e.g. for session initiation protocol [SIP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications
    • H04L65/403Arrangements for multi-party communication, e.g. for conferences
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/75Media network packet handling
    • H04L65/752Media network packet handling adapting media to network capabilities
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/75Media network packet handling
    • H04L65/762Media network packet handling at the source 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/75Media network packet handling
    • H04L65/765Media network packet handling intermediate
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/21Server components or server architectures
    • H04N21/218Source of audio or video content, e.g. local disk arrays
    • H04N21/2187Live feed
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/239Interfacing the upstream path of the transmission network, e.g. prioritizing client content requests
    • H04N21/2393Interfacing the upstream path of the transmission network, e.g. prioritizing client content requests involving handling client requests
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/472End-user interface for requesting content, additional data or services; End-user interface for interacting with content, e.g. for content reservation or setting reminders, for requesting event notification, for manipulating displayed content
    • H04N21/47202End-user interface for requesting content, additional data or services; End-user interface for interacting with content, e.g. for content reservation or setting reminders, for requesting event notification, for manipulating displayed content for requesting content on demand, e.g. video on demand
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/64Addressing
    • H04N21/6408Unicasting
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/643Communication protocols
    • H04N21/6437Real-time Transport Protocol [RTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements

Definitions

  • This application relates to the field of video playback, and in particular to a method, device, device, and system for sending media streams.
  • Video viewing includes live broadcast and on-demand.
  • the user can choose to fast forward or rewind the video content at any time while watching it, but it cannot choose for the live broadcast.
  • the so-called live broadcast can be broadly understood as a process in which each frame of data is tagged with time sequence and then streamed.
  • collection devices such as cameras and microphones continuously collect audio and video information, and then process the information through encoding, packetization, streaming, etc., and then transmit it through the distribution network.
  • the playback terminal continuously downloads the data and follows the sequence Perform decoding and playback.
  • the entire process of live video streaming can be divided into a series of processes such as collection, encoding, streaming, transcoding, distribution, and decoding/rendering.
  • Mainstream Internet video live broadcast manufacturers generally use unicast transmission protocol to transmit video, so for N users watching the video, there will be N video streams.
  • video live broadcasts carried out in enterprises it is required to support functions such as presentation document sharing and text comments while supporting live video. While displaying video content on the web page of the enterprise live broadcast, it is necessary to delay sharing documents and texts. Comment content to meet user needs and enhance user experience.
  • live broadcast platforms In order to improve user experience and save backbone network bandwidth, live broadcast platforms generally deploy live content delivery networks (Content Delivery Network, CDN).
  • CDN Content Delivery Network
  • the live CDN is a distributed content distribution platform that supports a multi-level architecture, and the servers used for caching can be deployed hierarchically and hierarchically, so as to provide nearby services for users in different regions.
  • the real-time messaging protocol (RTMP), or real-time messaging protocol, is generally used for the push and distribution process of the video; for the distribution process, RTMP, HLS ( HTTP Live Streaming and HyperText Transfer Protocol (HTTP)-Flash Video (FLV), referred to as "HTTP-FLV" three protocols.
  • HLS HTTP Live Streaming and HyperText Transfer Protocol (HTTP)-Flash Video (FLV), referred to as "HTTP-FLV” three protocols.
  • HLS HTTP Live Streaming and HyperText Transfer Protocol (HTTP)-Flash Video
  • HLS is Apple's HTTP-based streaming media transmission protocol, which is mainly used in iOS devices including iPhone, iPad, iPod touch and Mac OSX to provide audio and video live broadcast services and recorded content (on-demand) services.
  • HLS does not request a complete data stream at once, but cuts the streaming media data into continuous small files with shorter duration on the server side, and accesses the small files sequentially through the index file. As long as the client continuously plays these small files received from the server in sequence, it can play audio and video.
  • the content source sends audio and video media streams to the enterprise data center (Enterprise Data Center, EDC) via RTMP
  • EDC enterprise Data Center
  • the EDC includes a Web server (Web server) and multiple Media server
  • the Web server in the EDC is responsible for responding to the client's (PC) live viewing request, authenticating the user, and assigning a media server nearby to provide services according to the user's location.
  • the selected media server will send the audio and video media stream to the next-level Regional Data Center (RDC) according to the preset policy.
  • the media server in the RDC will receive the media stream (live content) after receiving the media stream (live content). , It will be sent to the next-level media server in the server room (SR) according to the preset strategy.
  • the media server in the computer room caches the media stream (live content) distributed by the upper-level media server and directly Provide users with live broadcast services.
  • the media server in the upper-level RDC needs to send the live media stream to each client in the live room requesting media streams, so that the upper-level media server must send it to every user in the live room
  • WAN wide area network
  • the embodiments of the application provide a method, device, device, and system for sending media streams, which are used to reduce the resource overhead of media servers sending media streams to clients in the same live broadcast room.
  • the embodiments of the application disclose the following technologies Program:
  • this application provides a method for sending a media stream.
  • the method provides a live media stream for a client entering a live broadcast room.
  • the method includes: the proxy server respectively receives a request from the same proxy client to enter the live broadcast room.
  • the first live room request message and the second live room request message wherein the first live room request message is from a first client, and the second live room request message is from a second client;
  • the proxy server receives the media server respectively The first live media stream sent to the first client through the proxy server and the second live media stream sent to the second client;
  • the proxy server determines the first live media stream according to the first live room request message The role of a client, and determine the role of the second client according to the second live room request message;
  • the proxy server is determining the role of the first client as the master user and the role of the second client as the servant In the case of the user, only the first live media stream is sent to the proxy client, so that the proxy client sends the first live media stream to the first client and the second client
  • the proxy client when requesting to obtain the live media stream, the proxy client only needs to directly send the first media stream requested by the first client in the primary user role cached locally To the second client, thereby avoiding the proxy server from sending the live media stream to the proxy client, the proxy server does not need to send the live media stream for each client that enters the live room through the proxy client, and the method reduces the proxy server The traffic of sending media streams with the proxy client effectively reduces the export bandwidth and saves resource overhead.
  • the first live broadcast room request message includes the identification of the proxy client
  • the second live broadcast room request message includes the proxy client's Identification
  • the method further includes: the proxy server determines the identification of the proxy client according to the identification of the proxy client included in the first live broadcast room request message, and the identification of the proxy client included in the second live broadcast room request message
  • the first live room request message and the second live room request message come from the same proxy client.
  • the proxy server can determine the receiving end object when forwarding the message and response, which facilitates message sending and receiving.
  • the proxy server determining the role of the second client according to the second live broadcast request message includes: In the second live room request message, whether there is a client in the live room that enters the live room through the proxy client in the role of the master user; if so, it is determined that the role of the second client is the servant user.
  • the proxy server only needs to determine whether there is a primary user in the live broadcast room to determine the identity role of the client entering the live broadcast room, and can quickly identify the role of the client and mark it .
  • the method further includes: the proxy server receives the proxy client A request message for exiting the live broadcast room sent by the client, where the request message for exiting the live broadcast room is used to request the first client to exit the live broadcast room; when the proxy server determines to use the second client as the new primary user , Changing the role of the second client from the servant user to the master user; and switching the first live media stream sent to the second client to the second live media stream.
  • the second client with the new main user role is used to request and obtain the live media stream from the media server, thereby ensuring that the second client is still in the live broadcast room.
  • the client's viewing of media content is not affected, and the user experience of the second client's user in the live broadcast room is guaranteed.
  • the last frame of the first live media stream sent by the proxy server to the second client is the same as the last frame sent to the second client
  • the first frame of the second live media stream is an adjacent frame; before the proxy server switches the first live media stream sent to the second client to the second live media stream, the method further includes: proxy The server identifies the first I frame and the second I frame belonging to the first live media stream and the second live media stream according to the first live media stream and the second live media stream, and the first The I frame and the second I frame are the same video frame.
  • the proxy server determines, according to the first I frame and the second I frame, adjacent first switching frames and second switching frames that belong to the first live media stream and the second live media stream, and Use the first switching frame and the second switching frame as the last frame of the first live media stream sent to the second client, respectively, and the second live broadcast sent to the first client
  • the proxy server determining the role of the second client according to the second live room request message includes: the proxy server receives the second When requesting a message in the live broadcast room, it is judged whether the number of clients that enter the live broadcast room through the proxy client as the main user reaches a preset upper limit, and the preset upper limit is greater than or equal to 2 and a positive integer; if it reaches the If the upper limit is preset, it is determined that the role of the second client is a servant user.
  • the size between the number of clients in the primary user role in the live broadcast room and the preset upper limit is calculated To determine the role of the client. Understandably, the role of the client can also be determined in other ways, for example, according to the number of requests for the live broadcast room, which is not limited in this embodiment.
  • the proxy server determines The role of the second client is the backup master user.
  • the method further includes: the agent The server receives a request message for exiting the live broadcast room from the first client; the proxy server changes the role of the second client from the servant user to the backup master user when determining to use the second client as the new backup master user; The proxy server buffers the received second live media stream in a unit of a group of pictures GOP.
  • the proxy server receives the second live media stream from the media server and stores it locally, so as to provide the client in the live room when the user role is subsequently changed. The cached second live media stream.
  • the method further includes: The proxy server caches the received second live media stream in units of GOPs; according to the identification of the first live media stream and the cached second live media stream that belong to the first live media stream and the second live media stream, respectively The first I frame and the second I frame of the live media stream, where the first I frame and the second I frame are the same video frame.
  • the method further includes: the proxy server receives a request message for exiting the live broadcast room from the first client; When a new primary primary user is used, the role of the second client is changed from the backup primary user to the primary primary user; the proxy server determines the adjacent and the second I frame according to the first I frame and the second I frame. Belong to the first switching frame and the second switching frame of the first live media stream and the second live media stream respectively; the proxy server will send the first switching frame to the first switching frame and the second switching frame according to the first switching frame and the second switching frame.
  • the first live media stream sent by the second client is switched to the second live media stream, wherein the last frame of the first live media stream sent by the proxy server to the second client is the first switch Frame, the first frame of the second live media stream sent to the first client is the second switching frame.
  • the role of the second client changes from the backup master user to the primary master user
  • the second live media stream from the media server is received and cached, and the cached second live media stream is copied and distributed to the live broadcast room To ensure that other clients in the live broadcast room can watch the live content normally without being affected.
  • the proxy server caches the first live media stream and the second live media stream in units of GOPs.
  • the 3 GOPs of the first live media stream and the 3 GOPs of the second live media stream are cached locally on the proxy server.
  • an embodiment of the present application also provides a method for sending a media stream.
  • the method provides a live media stream for a client entering a live broadcast room.
  • the method includes: the proxy client respectively receives a message sent by the first client for A request message for the first live room requesting to enter the live room, and, the second client sends a second live room request message for requesting to enter the live room, and the proxy client sends the first live room request to the media server through the proxy server Message and the second live room request message, the proxy client receives the first live media stream sent by the proxy server, and the first live media stream is the media server to the first client through the proxy server
  • the role of the first client is the master user
  • the role of the second client is the servant user
  • the proxy client sends the first live media stream to the first client and the second client.
  • the proxy server for all users accessing the live room from the same proxy client, the proxy server only needs to send a live media stream to the proxy client, that is, the proxy client only needs to consume a wide area bandwidth to receive Compared with the transmission resources occupied by the media server to send the live media stream to each client in the live room, the live media stream sent by the proxy server reduces the load of the WAN network link and saves transmission overhead.
  • the method before the proxy client sends the first live room request message to the media server through the proxy server, the method further includes: the proxy client sends the Adding the identifier of the proxy client to the first live room request message; and, before the proxy client sends the second live room request message to the media server through the proxy server, the method further includes: the proxy client The identifier of the proxy client is added to the second live room request message.
  • the method further includes: the proxy client uses the group of pictures GOP Cache the first live media stream for the unit.
  • the method before the proxy client sends the first live media stream to the second client, the method further includes: The time stamp of the first live media stream is such that the adjusted time stamp satisfies: the time stamp of the first frame of the first live media stream sent by the proxy client to the second client is 0, and the second The time stamps of adjacent frames of the first live media stream sent by the client are continuous.
  • the method further includes: the proxy client receiving the first sent by the proxy server 2.
  • a live media stream is a media stream sent by a media server to a second client through the proxy client, and the second client is a client whose role is changed from a servant user to a master user;
  • the proxy client sends the second live media stream to the second client.
  • the method before the proxy client sends the second live media stream to the second client, the method further includes: The timestamp of the second live media stream is such that the adjusted timestamp satisfies: the timestamp of the first frame of the second live media stream sent by the proxy client to the second client The time stamp of the last frame of the first live media stream sent by the client is continuous.
  • an apparatus for sending a media stream includes: the apparatus includes a unit for executing the method steps in the foregoing first aspect and various implementation manners of the first aspect.
  • the device includes a receiving unit, a processing unit, and a sending unit.
  • it may also include other modules or units such as a storage unit.
  • the device is a proxy server.
  • an apparatus for sending a media stream in an embodiment of the present application includes: the apparatus includes a unit for executing the above-mentioned second aspect and the method steps in the various implementation manners of the second aspect.
  • the device includes a receiving unit, a processing unit, and a sending unit.
  • it may also include other modules or units such as a storage unit.
  • the device is a proxy client.
  • an embodiment of the present application also provides a network device, including a transceiver, a processor, and a memory, the processor is coupled to the memory, and the memory is used to store instructions; and the processor is used to call all
  • the instruction causes the network device to execute the media stream sending method in the foregoing first aspect and various implementations of the first aspect, or calls the instruction to cause the network device to execute the foregoing second aspect and various implementations of the second aspect
  • the media stream sending method in the mode including a transceiver, a processor, and a memory, the processor is coupled to the memory, and the memory is used to store instructions; and the processor is used to call all
  • the instruction causes the network device to execute the media stream sending method in the foregoing first aspect and various implementations of the first aspect, or calls the instruction to cause the network device to execute the foregoing second aspect and various implementations of the second aspect The media stream sending method in the mode.
  • the network device is a proxy server, or a proxy client.
  • the transceiver when the network device serves as a proxy server, the transceiver is configured to respectively receive the first live room sent by the same proxy client for requesting to enter the live room
  • the request message and the second live room request message respectively receive the first live media stream sent by the media server to the first client through the proxy server and the second live media stream sent to the second client, where
  • the first live room request message comes from a first client
  • the second live room request message comes from a second client
  • the processor is configured to determine the first client according to the first live room request message And determine the role of the second client according to the second live room request message
  • the transceiver is also used to determine the role of the first client as the master user and the role of the second client In the case of a servant user, only the first live media stream is sent to the proxy client, so that the proxy client sends the first live media stream to the first client and the The second client.
  • the transceiver when the network device serves as a proxy client, the transceiver is configured to respectively receive the first client sent by the first client for requesting to enter the live broadcast room. A live room request message, and a second live room request message sent by the second client for requesting to enter the live room; and, sending the first live room request message and the media server through a proxy server The second live broadcast request message; the transceiver is also used to receive the first live media stream sent by the proxy server, and send the first live media stream to the first client and the second Client.
  • the first live media stream is a media stream sent by the media server to the first client through the proxy server, the role of the first client is the master user, and the role of the second client is Servant user.
  • the embodiments of the present application also provide a computer-readable storage medium.
  • the storage medium stores instructions.
  • the instructions run on a computer or a processor, they are used to execute the aforementioned first aspect and the first aspect.
  • the embodiments of the present application also provide a computer program product.
  • the computer program product includes computer instructions. When the instructions are executed by a computer or a processor, the foregoing first aspect and various aspects of the first aspect can be implemented. The method in the implementation manner, or the method in the foregoing second aspect and various implementation manners of the second aspect.
  • an embodiment of the present application also provides a media stream sending system.
  • the system includes at least one client, a proxy client, a proxy server, and a media server, wherein each of the clients passes through the proxy client
  • the system implements the media stream sending methods described in the foregoing first aspect, second aspect, and various implementation manners of the first or second aspect through the proxy client and the proxy server.
  • the proxy client is used to execute the media stream sending method described in the second aspect or any implementation manner of the second aspect
  • the proxy server is used to execute the media stream sending method described in the first aspect or any implementation manner of the first aspect.
  • the proxy server is the media sending device described in the foregoing third aspect or any implementation manner of the third aspect
  • the proxy client is the foregoing fourth aspect or any implementation manner of the fourth aspect Said media sending device.
  • the proxy server and the media server are located in a regional data center RDC, the RDC also includes a Web server, and the Web server is used to The proxy client enters the live broadcast room to assign the media server to the client.
  • system further includes an enterprise data center EDC and a content source.
  • the media stream sending system is a content distribution network CDN system.
  • an embodiment of the present application also provides a chip system, the chip system includes a processor and an interface circuit, the interface circuit is coupled with the processor, and the processor is used to execute a computer program or instruction to implement the foregoing The first aspect and the methods in the various implementations of the first aspect, or the methods in the foregoing second aspect and the various implementations of the second aspect; wherein the interface circuit is used to communicate with other than the chip system The module communicates.
  • the method provided in this application uses the proxy client and proxy server to obtain the live media stream requested by the main user’s client, and cache some media stream fragments locally on the proxy client.
  • the proxy client directly sends the locally cached media streams to these clients, thereby avoiding the proxy server from sending live media streams to the proxy client.
  • only one live media stream requested by the main user client is sent between the proxy server and the proxy client, that is, only a wide area bandwidth is needed to transmit the live media stream, compared to the media server through the proxy server
  • the traffic of sending the media stream is reduced, the load of the WAN network link is reduced, and the resource overhead is saved.
  • the proxy client also adjusts the timestamp of the live media stream when sending a live media stream to all clients in the live room. For example, when the first client in the primary user role exits the live room, the proxy client will When the first live media stream sent to the second client is switched to the second live media stream, the timestamp of the second live media stream is adjusted so that the proxy client sends the second live media stream to the second client Seamlessly connect the media content of the first live media stream that was originally being played, to avoid video jams or other effects on the media content viewed by the second client due to the exit of the first client, so this method adjusts the timestamp through the proxy client The user viewing experience is also guaranteed.
  • FIG. 1 is a schematic diagram of a live broadcast system architecture provided by this application.
  • FIG. 2 is a schematic diagram of the architecture of a video live broadcast bilateral agency system provided by an embodiment of the application;
  • FIG. 3 is a flowchart of a method for sending a media stream according to an embodiment of the application
  • FIG. 4 is a flowchart of another media stream sending method provided by an embodiment of the application.
  • FIG. 5 is a signaling flowchart of a method for sending a media stream according to an embodiment of the application
  • FIG. 6 is a signaling flowchart of another media stream sending method provided by an embodiment of the application.
  • FIG. 7 is a signaling flowchart of another method for sending a media stream according to an embodiment of the application.
  • FIG. 8 is a signaling flowchart of another method for sending a media stream according to an embodiment of the application.
  • FIG. 9 is a schematic structural diagram of a media stream sending device according to an embodiment of the application.
  • FIG. 10 is a schematic structural diagram of a network device provided by an embodiment of this application.
  • the technical solution of the present application can be applied to a content delivery network (CDN) system, and the newly added devices in the system include a proxy server (proxy server) and a proxy client (proxy client).
  • CDN content delivery network
  • the proxy server is used to proxy the user's video bearer protocol, identify the roles of all clients that enter the live room through the proxy server, obtain at least one live media stream from the media server, and set the role as the live media stream of the main user identity Sent to the proxy client.
  • the proxy server is also used to update the roles of other users in the live broadcast room and switch the new live media stream when the client in the main user role exits the live broadcast room.
  • the proxy client is used to proxy the user's video bearer protocol, receives the live media stream of the client whose role is the main user sent by the proxy server, and copies and distributes the live media stream to the live room accessed through the proxy client All clients in.
  • the proxy server may be located in a regional data center (Region Data Center, RDC).
  • RDC Regional Data Center
  • the proxy server may be specifically deployed on a server, or may also be deployed on a Universal Customer Premise Equipment (uCPE) in the form of Network Functions Virtualization (NFV).
  • uCPE Universal Customer Premise Equipment
  • NFV Network Functions Virtualization
  • the proxy client may be a device located at the edge of the local area network, and the client in the local area network enters the live room through the proxy client and obtains the live media stream through the proxy client.
  • the proxy client can be deployed on a server, or deployed on uCPE in the form of NFV.
  • this embodiment provides a video CDN system, which includes: content source (content source) 101, enterprise data center (enterprise data center, EDC) 102, RDC 103, proxy client 104. At least one client (client, C), such as a first client C1 105, a second client C2 106, and a third client C3 107.
  • EDC 102 includes multiple media servers (media servers) and Web servers (Web servers)
  • RDC 103 includes proxy servers, multiple media servers, and Web servers.
  • the proxy server and the proxy client are connected through a WAN network, and the proxy client and at least one client associated with it are connected through a local area network (LAN).
  • LAN local area network
  • the CDN live broadcast is a distributed content distribution platform that supports a multi-level architecture. By deploying multiple media servers hierarchically and hierarchically, it provides nearby services to users in different regions. Among them, when the users in the EDC watch the live broadcast in the live broadcast room, the allocated media server can be deployed in the RDC, and the live broadcast media transmitted circulates too much. Client.
  • the proxy server may correspond to one or more proxy clients.
  • the proxy server corresponds to proxy client 1 and proxy client 2.
  • the client of LAN 1 enters the live room through proxy client 1 and the proxy server; the client of LAN 2 enters the live room through proxy client 2 and the proxy server. Studio.
  • the proxy server may determine the role of each client that enters the live broadcast room through the proxy server through the following embodiment A or embodiment B.
  • Implementation A The role of the client is uniformly determined for all clients that enter the live broadcast room through the same proxy client.
  • the proxy server corresponds to the proxy client 1 and the proxy client 2. It determines at least one master user among the clients that enter the live broadcast room through the proxy client 1, and determines the other clients as servant users.
  • the proxy client 2 determines at least one master user among the clients entering the live broadcast room, and determines other clients as servant users.
  • the proxy server sends the live media stream of the client whose role is the primary user to the proxy client, and then the proxy client sends the live media stream to the The proxy client enters all clients in the live broadcast room.
  • the clients that enter the live broadcast room through each proxy client include the client whose role is the main user, and the proxy server sends media to any proxy client.
  • Streams are all media streams of the client that enters the live broadcast room through the proxy client and the role of the primary user.
  • Embodiment B The role of the client is uniformly determined for all clients entering the live broadcast room through the proxy server.
  • the proxy server corresponds to proxy client 1 and proxy client 2, and determines at least one master user among all the clients that enter the live broadcast room through proxy client 1 and proxy client 2, and determines other clients as servants. user.
  • the role of the client is determined in Embodiment B, correspondingly, the live media stream of the client whose role is the primary user is sent to each proxy client corresponding to the proxy server in the system, and then each proxy client Send the live media stream to all clients that enter the live room through their respective proxy clients.
  • the role described is the client of the master user, which can be referred to simply as: the client of the master user.
  • the role is the client of the servant user, which can be referred to simply as: the client of the servant user.
  • a media stream sending method provided by this embodiment, the method provides live media streams for all clients that enter the live room through the same proxy client. Specifically, the method includes:
  • Step 101 The proxy server respectively receives the first live room request message and the second live room request message sent by the same proxy client for requesting to enter the live room, wherein the first live room request message comes from the first client, and the second live room request message The time request message comes from the second client.
  • the first live room request message includes the identification of the proxy client
  • the second live room request message includes the identification of the proxy client
  • the identification may be the IP address or port number of the proxy client, etc.
  • the proxy server may determine the proxy client that forwards the first live room request message according to the identifier of the proxy client included in the first live room request message, and according to all the proxy clients included in the second live room request message
  • the identifier of the proxy client determines the proxy client that forwards the second live room request message, and it can be determined that the first live room request message and the second live room request message are from the same proxy client.
  • Step 102 The proxy server respectively receives the first live media stream sent by the media server to the first client through the proxy server and the second live media stream sent to the second client.
  • the proxy server forwards the first media request message to the media server, and receives a message sent by the media server according to the first media request message.
  • the first live media stream and, after receiving the second media request message sent by the second client, forward the second media request message to the media server, and receive the media server according to the second media request The second live media stream sent by the message.
  • Step 103 The proxy server determines the role of the first client according to the first live room request message, and determines the role of the second client according to the second live room request message.
  • Embodiment A can be used to implement step 103.
  • the proxy server determines whether there is a request message for a live broadcast room (such as the second live broadcast room request message) every time a request message for a live broadcast room exists in the live broadcast room.
  • the role of the proxy client entering the live room is the client of the master user; if it exists, it is determined that the role of the client (such as the second client) that sends the request message for the live room is the slave user. ). If it does not exist, it is determined that the role of the client is a master user (master user).
  • step 103 specifically includes: each time the proxy server receives a live room request message (as described in the first (2) Live room request message), to determine whether the number of clients in the current live room that enter the live room through the proxy client in the role of the main user reaches a preset upper limit, the preset upper limit is greater than or equal to 2, and if it reaches all According to the preset upper limit, it is determined that the role of the client (such as the second client) that sends the live room request message is a servant user. If the preset upper limit is not reached and the number is not 0, it is determined that the role of the client is a secondary-master user. If the number is 0, it is determined that the role of the client is the main-master user.
  • Embodiment B may also be used to implement step 103, and the specific implementation manner is similar to the foregoing specific implementation manner of "Embodiment A".
  • the only difference from the specific implementation of "Embodiment A” is that it is determined whether there is a role of the primary user in the live broadcast room that enters the live broadcast room through the proxy server Client.
  • the only difference from the specific implementation of "Embodiment A” is that it is determined that the role of the primary user’s client in the current live broadcast room that enters the live broadcast room through the proxy server Whether the quantity reaches the preset upper limit.
  • the proxy server caches the first live media stream in a unit of a group of pictures (GOP).
  • GOP can refer to the image sequence between two I-frames.
  • the I-frame is also known as an intra picture, which generally refers to each image processed by moving picture experts group (MPEG) technology.
  • MPEG moving picture experts group
  • the MPEG technology processing includes moderately compressing the video image, so that the first frame can be used as a reference point for random access, and there is no need to refer to other pictures.
  • 3 GOPs are cached locally on the proxy server, and the duration of each GOP is 5s.
  • Step 104 When the proxy server determines that the role of the first client is the master user and the role of the second client is the servant user, the proxy server only sends the first live media stream to the proxy client to Enabling the proxy client to send the first live media stream to the first client and the second client.
  • the proxy server receives the first live room request message in step 101, receives the first live media stream in step 102, and determines the role of the first client as the master in step 103.
  • the user because the role of the first client is the master user, in step 104, the live media stream of the first client (that is, the first live media stream) is sent to the proxy client, and accordingly, The proxy client sends the first live media stream to the first client.
  • the proxy server receives the second live room request message in step 101, receives the second live media stream in step 102, and determines the role of the second client as a servant user in step 103.
  • the role of the second client is a servant user and corresponds to the same proxy client as the first client.
  • the proxy server does not send the media stream of the second client to the proxy client (that is, the The second live media stream). Accordingly, after receiving the first live media stream sent by the proxy server, the proxy client not only sends the first live media stream to the first client, but also copies the first live media stream. Live the media stream, and send the copied first live media stream to the second client. Understandably, if more clients are included in the live broadcast room, the proxy client copies multiple copies of the first live media stream, and sends the copied first live media stream to the proxy client to enter the Every client in the live room.
  • the role of the first client may be the main master user, and the second client may be the servant user or the backup master user.
  • the proxy server is only the first live media requested by the first client The stream is sent to the proxy client.
  • the proxy server will also correspondingly send the first live media stream to other proxy clients, and the other proxy The client terminal copies and distributes the received first live media stream to the corresponding client terminal.
  • the proxy client when requesting to obtain the live media stream, the proxy client only needs to send the first media stream requested by the first client in the master user role cached locally To the second client, thereby avoiding the proxy server from sending the live media stream to the proxy client, the proxy server does not need to send the live media stream for each client that enters the live room through the proxy client, and the method reduces the proxy server The traffic of sending media streams with the proxy client effectively reduces the export bandwidth and saves resource overhead.
  • this embodiment also includes the process of changing the role of the client.
  • the method further includes : The proxy server receives a request message for exiting the live broadcast room sent by the proxy client, and the request message for exiting the live broadcast room is used to request the first client to exit the live broadcast room; the proxy server is determining to transfer the second client As a new master user, change the role of the second client from the servant user to the master user (slave-to-master), and the proxy server will send the first live media to the proxy client The stream is switched to the second live media stream, so that the proxy client sends the second live media stream to the clients (including the second client) that enter the live broadcast room through the proxy client end).
  • the last frame of the first live media stream sent by the proxy server to the proxy client and the first frame of the second live media stream sent to the second client are adjacent frames.
  • the proxy server switches the first live media stream sent to the second client to the second live media stream, it also includes media stream alignment A step of.
  • the media stream alignment step specifically includes: the proxy server identifies the first I frame and the second I frame belonging to the first live media stream and the second live media stream according to the first live media stream and the second live media stream.
  • the proxy server determines according to the first I frame and the second I frame that adjacent ones belong to the first live broadcast Media stream and the first switching frame and the second switching frame of the second live media stream, and using the first switching frame and the second switching frame as the first switching frame sent to the second client The last frame of a live media stream and the first frame of the second live media stream sent to the first client.
  • the proxy server forwards the request message for exiting the live broadcast room from the first client to the media server.
  • the process of the corresponding client exiting the live broadcast room includes: when the first client is the main master user and the second client is the servant user, the first client The client requests to exit the live broadcast room, and the proxy server receives a request message from the first client to exit the live broadcast room.
  • the proxy server sends The role is changed from the servant user to the backup master user; the proxy server receives the second live media stream sent by the media server in real time, and caches the second live media stream in GOP units.
  • the proxy server caches the second live media stream of the backup master user locally, so that when the role of the backup master user is changed to the master master user, it can directly Using the second live media stream improves the transmission efficiency of the media stream.
  • the process of the first client exiting the live broadcast room includes: the proxy server receives from the first client The proxy server changes the role of the second client from the backup master user to the primary master user (secondary-master to a request message for exiting the live broadcast room) when determining to use the second client as the new primary master user. main-master), and switch the first live media stream sent to the proxy client to the second live media stream.
  • the proxy server caches the received media stream of the client every time after confirming that a new role is the client of the backup primary user, and takes the cached media stream of the client and the current role as the main
  • the media streams of the client of the primary user are aligned, that is, the media streams of the client whose role is the primary primary user and the media streams of the client whose role is the backup primary user are cached to identify the same video frames belonging to the two media streams. .
  • the received second live media stream is buffered in GOP units, and the first live media stream and the second live media stream are identified as belonging to the first live media respectively
  • the first I frame and the second I frame of the stream and the second live media stream, the first I frame and the second I frame are the same video frame.
  • the proxy server determines, according to the first I frame and the second I frame, neighboring ones that belong to the first live media stream and the first live media stream, respectively. 2.
  • the proxy server switches the first live media stream sent to the second client to the first according to the first switching frame and the second switching frame Two live media streams, wherein the last frame of the first live media stream sent to the second client is the first switching frame, and the first frame of the second live media stream sent to the first client The frame is the second switching frame.
  • the embodiment of the present application also provides a media stream sending method, which can be applied to a proxy client. Further, as shown in Figure 4, the method includes:
  • Step 201 The proxy client respectively receives a first live room request message sent by the first client to request to enter the live room, and a second live room request sent by the second client to request to enter the live room news.
  • Step 202 The proxy client sends the first live room request message and the second live room request message to the media server through the proxy server.
  • the proxy client may also add the identifier of the proxy client to the first live room request before forwarding the first live room request message to the proxy server, and, before forwarding it to the proxy server Before the second live room request message, the identifier of the proxy client is added to the second live room request.
  • the identifier of the proxy client is the IP address of the proxy client.
  • Step 203 The proxy client receives a first live media stream sent by the proxy server, where the first live media stream is a media stream sent by the media server to the first client through the proxy server, and The role of the first client is the master user, and the role of the second client is the servant user.
  • Step 204 The proxy client sends the first live media stream to the first client and the second client.
  • the proxy client before sending the first live media stream, the proxy client further includes: buffering the first live media stream in a GOP unit, and adjusting the timestamp of the first live media stream.
  • the proxy client receives the first live room request message of the first client, and in step 202 forwards the first live room request message to the proxy server, because the proxy server
  • the first client is determined as the master user
  • the proxy client receives the live media stream of the first client (ie, the first live media stream) in step 203, and sends the first live media stream to the second client in step 204 One client.
  • the proxy client receives the second live room request message of the second client, and in step 202 forwards the second live room request message to the proxy server, because the proxy server has the second client
  • the client is determined to be a servant user, so the proxy client does not receive the live media stream of the second client (that is, the second live media stream), but directly executes step 204 to copy and send the first live media stream to the second client.
  • the proxy client When copying and sending the first live media stream to the second client, the proxy client also adjusts the timestamp of the first live media stream so that the first live media stream sent to the second client meets:
  • the time stamp of the first frame of the first live media stream sent by the client to the second client is 0; and the time stamps of adjacent frames of the first live media stream sent to the second client are continuous Yes, the “continuous” means that the time interval between adjacent frames of the first live video stream is the same, which is the reciprocal of the frame rate f of the first live video stream.
  • the method further includes: when the first client exits the live broadcast room, the proxy client forwards the related process of the first client's exit live broadcast request message, which specifically includes: the proxy client receives the request to exit the live broadcast room from the first client Message, send the quit live broadcast room request message to the proxy server; receive the quit live broadcast response message sent by the proxy server according to the quit live broadcast request message, and send the quit live broadcast response message to The first client.
  • the proxy client forwards the related process of the first client's exit live broadcast request message, which specifically includes: the proxy client receives the request to exit the live broadcast room from the first client Message, send the quit live broadcast room request message to the proxy server; receive the quit live broadcast response message sent by the proxy server according to the quit live broadcast request message, and send the quit live broadcast response message to The first client.
  • it also includes: when the proxy client receives the first live room request message, marking the role of the first client as working; when the second live room request message is received In this case, the role of the second client is marked as work; in the case of receiving a request message for exiting the live broadcast room sent by the first client, the role of the first client is marked as exiting. And update the role mark of the first client to the "live room user relationship table".
  • the method further includes: the proxy client receives a second live media stream sent by the proxy server, and the second live media stream is the media server through the proxy client A media stream sent by the client to a second client, the second client being a client whose role is changed from a servant user to a master user; the proxy client sends the second live media stream to the second client.
  • the method further includes: the proxy client adjusts the timestamp of the second live media stream so that the adjusted time The stamp satisfies: the time stamp of the first frame of the second live media stream sent by the proxy client to the second client and the time of the last frame of the first live media stream sent to the second client Poke continuously. Further, the last frame of the first live media stream sent by the proxy client to the second client and the first frame of the second live media stream sent to the second client are adjacent frames.
  • the proxy server adjusts the timestamp of the media stream according to the formula so that the adjusted timestamp meets the following constraints:
  • the timestamp of the first frame of the live media stream sent by the proxy client to the second client is 0;
  • the time stamps of the adjacent frames of the live media stream sent by the proxy client to the second client are continuous, that is, the time interval of the adjacent frames of the sent live media stream is the same, and the time interval is the live video
  • the frame rate of the stream is the inverse of f.
  • ⁇ t is the time before adjustment of the first frame of the live media stream sent by the proxy client to the second client The opposite of poke.
  • the GOP of the first live media stream cached by the proxy client is 5 seconds (s), and 3 GOPs are cached locally.
  • the content of each GOP is updated in real time.
  • the first client (Client C1 for short) is the first client to enter the live broadcast room, and the role of client C1 at the 0th second is the main user, and continues to watch the first live media stream in the live broadcast room until the 60s Duration.
  • the 3 GOPs of the video media stream cached locally by the proxy client are: 45s-50s, 50s-55s, 55s-60s media content, these 3 GOPs are the media server passing the proxy server For the media stream segment sent to the client C1, the timestamp corresponding to each frame sent is the relative time of the client C1.
  • the second client enters the live broadcast room at the 60th second, and the role is a servant user.
  • the proxy client needs to send the latest first live media stream sent to client C1 and locally cached to the client C2.
  • the live media stream closest to 60s is the third GOP segment, and the media content of the 55s-60s is cached.
  • 55s is the timestamp of the frame sent by the media server.
  • the proxy server when the client C1 requests to exit the live broadcast room, the proxy server needs to switch the first live media stream sent to the client C2 to the second live media stream, and the role of the client C2 is changed to the main user at this time , And the second live broadcast media stream is a media stream sent by the media server to the client C2.
  • the proxy client receives the second live media stream sent by the media server, and adjusts the timestamp of the second live media stream.
  • the proxy server determines to change the role of the client C2 as the primary user, and then the proxy server sends the second live media stream of the client C2 to the proxy client.
  • the proxy client receives and caches the second live media stream. It is assumed that the media content of the 3 GOPs locally cached by the proxy client are: 105s-110s, 110s-115s, 115s-120s, After 10s, the proxy client caches the latest GOP 1 as the 115th-120s video content.
  • the time stamp on the frame in this GOP 1 is the relative time of client C1.
  • the proxy client when it adjusts the timestamp, it can be divided into two situations to calculate the time difference. Specifically,
  • the proxy client and proxy server when used to obtain the live media stream requested by the client of the main user, some media stream fragments are cached locally at the proxy client.
  • the proxy client When other clients enter the live room and request live media When streaming, the proxy client directly sends the locally cached media streams to these clients, thereby avoiding the proxy server from sending live media streams to the proxy client.
  • only one live media stream requested by the main user client is sent between the proxy server and the proxy client, that is, only a wide area bandwidth is needed to transmit the live media stream, compared to the media server through the proxy server
  • the traffic of sending the media stream is reduced, the load of the WAN network link is reduced, and the resource overhead is saved.
  • the proxy client also adjusts the timestamp of the live media stream when sending a live media stream to all clients in the live room. For example, when the first client in the primary user role exits the live room, the proxy client will When the first live media stream sent to the second client is switched to the second live media stream, the timestamp of the second live media stream is adjusted so that the proxy client sends the second live media stream to the second client Seamlessly connect the media content of the first live media stream that was originally being played, to avoid video jams or other effects on the media content viewed by the second client due to the exit of the first client, so this method adjusts the timestamp through the proxy client The user viewing experience is also guaranteed.
  • This embodiment provides a method for sending a live video media stream.
  • the method can be applied to the live video system shown in FIG. 2.
  • the method includes a proxy server sending a first client that enters the live room through the same proxy client and
  • the second client provides a live media stream, where the live media stream comes from a content source and is forwarded through a media server in the RDC.
  • the method includes 39 steps (steps, S) in total, from S1 to S39.
  • client C1 the first client
  • client C2 the second client
  • the process for the client C1 to enter the live room and obtain the live media stream includes:
  • the content source sends the first live media stream to the media server in the EDC.
  • the media server in the EDC receives the first live media stream, and sends the first media stream to the media server in the next-level RDC. Wherein, before sending the first live media stream, it also includes: the step of the Web server in the EDC to authenticate the media server in the next level RDC, if and only if the authentication result is qualified, the media server in the RDC will be the first The live media stream is sent to the media server in the RDC.
  • S2 further includes: a proxy server that identifies the transmission protocol corresponding to the proxy client according to the service characteristics of the first live media stream; wherein, the service characteristics include the IP address and port number of the Web server, For example, for the HyperText Transfer Protocol (HTTP) protocol, the configurable service features include: the IP address and port number of the Web server. Further, it can be determined that the transmission protocol corresponding to the HTTP protocol is Transmission Control Protocol (TCP), so as to use the TCP protocol to transmit the media stream.
  • TCP Transmission Control Protocol
  • the client C1 sends a request message of an accessible media server to the Web server in the RDC. Further, the request message includes: the user name, IP address, live room name of the client C1, the key Token obtained by the client C1 after authentication, and other information, where the IP address is used to determine the location of the client C1 .
  • the client C1 sends the request message to the proxy client, and the proxy client forwards the request message to the proxy server after receiving the request message, and then the proxy server forwards the request message to the Web server in the RDC.
  • the Web server in the RDC receives the request message, and sends a response message of an accessible media server to the client C1, where the response message is used to inform the client C1 of the media server it can access.
  • the Web server determines, according to the request message, a target media server that can provide media streaming services for the client C1, where the target media server is one of multiple media servers in RDC, and then sends the response message to the client
  • the response message includes relevant information of the target media server, such as uniform resource locator (URL) information, IP address, and port number of the target media server.
  • URL uniform resource locator
  • the Web server in the RDC sends the response message to the proxy server, the proxy server sends the response message to the proxy client, and the proxy client forwards the response message to the client C1.
  • the Web server determines the location of the client C1 according to the IP address carried in the request message for accessing the media server sent by the client C1, and selects the media server that is closer to the client C1 as the target media according to the location information server.
  • the response message carries relevant information of the target media server, such as the URL information, IP address, and port number of the target media server. Therefore, when the proxy server and the proxy client forward the response message, the client The information of the media server that the terminal C1 can access, that is, the relevant information of the target media server.
  • the client C1 sends a first live room request message for requesting to enter the live room to the proxy client.
  • the first live room request message indicates that the client C1 requests to enter the live room.
  • the first live broadcast room request message includes the user name, IP address, port number, live broadcast room name, and Token obtained after authentication of the client C1.
  • the proxy client receives the first live room request message sent by the client C1, and sets the role of the client C1 to a working state.
  • a "live room user relationship table" is established, and a record about client C1 is added to the user relationship table in the live room.
  • the recorded content includes: the IP address, port number, user status, and user name of client C1 , The IP address and port number of the target media server selected in RDC, the name of the live broadcast room and other information.
  • the user status of the client C1 is working.
  • the IP address of the client C1 may be a primary key (primary key) stored in the database.
  • the proxy client adds its own identifier to the first live broadcast room request message, and the identifier of the proxy client is the IP address or port number of the proxy client.
  • the proxy client sends the first live room request message with the proxy client identifier added to the proxy server, where the modified first live room request message includes: the proxy client's identifier, the client The user name of the terminal C1, the name of the live broadcast room, and the token obtained after authentication.
  • the proxy server receives the modified first live room request message, determines the role of the client C1 according to the first live room request message, and refreshes the user relationship table in the live room.
  • determining the role of the client C1 includes: determining whether there is a client whose role is the main user among the clients that enter the live broadcast room through the proxy client when the first live broadcast room request message is received ; If it exists, it is determined that the client C1 is a servant user; if it does not exist, it is determined that the client C1 is a master user.
  • the proxy server since the client C1 is the first user to enter the live room through the proxy client, there is no master user, so when the proxy server receives the first live room request message, it determines that the role of the client C1 is The master user, and identifies the role of the client C1 as the master user.
  • the proxy server also includes: after determining the role of the client C1, the proxy server refreshes the “user relationship table in the live broadcast room”, marking the role of the client C1 as the main user. Understandably, the proxy server can update the "live room user relationship table" at any time according to the received live room request message sent through the same proxy client, so as to record the role status of each client in the live room at all times. Optionally, the proxy server also records the identification (IP address and port number) of the proxy client in the "live room user relationship table".
  • the number of clients that set the role of the master user in the live broadcast room is 1, that is, there is only one master user in the live broadcast room, and the rest of the clients are all servant users.
  • it can be called a single master user scenario .
  • the proxy server sends the first live broadcast room request message to the media server in the RDC.
  • the first live broadcast room request message does not include the identifier of the proxy client.
  • the media server in the RDC receives the first live room request message, and sends the first live room response message to the client C1.
  • the first live broadcast room response message is used to notify the client C1 that it has successfully entered the live broadcast room.
  • the media server first forwards the first live room response message to the proxy client through the proxy server, and then the proxy client forwards the first live room response message to the client C1.
  • the client C1 sends a first media request message to the proxy client, where the first media request message is used to request the media server to obtain the first live media stream.
  • the first identifier of the client C1 carried in the first media request message, and the first identifier is used to uniquely identify the client C1.
  • the first identifier includes the client C1's IP address and user name, etc.
  • the proxy client receives the first media request message, it forwards it to the proxy server, and the proxy server sends the first media request message to the media server in the RDC.
  • the media server After receiving the first media request message, the media server sends a first media response message to the client C1.
  • the first media response message is used to notify the client C1 to allow obtaining the first live media stream.
  • the media server sends the first media response message to the proxy server, and then the proxy server forwards the first media response message to the proxy client, and finally the proxy client forwards the first media response message to the client C1.
  • S14 The media server sends the first live media stream to the proxy server.
  • the proxy server obtains the first live media stream sent by the media server in real time, and then caches the first live media stream locally. Specifically, the proxy server locally caches the first live media stream segment in units of GOPs, such as Cache the latest 3 GOP media stream segments, respectively: t1-t2, t2-t3, t3-t4.
  • S16 The proxy server sends the buffered first live media stream segment to the proxy client, so that the proxy client sends the first live media stream to the client C1.
  • the proxy client receives the first live media stream sent by the proxy server, and caches the first live media stream locally in a GOP unit. Among them, the proxy client only caches a number of the latest first live broadcast media stream fragments.
  • the proxy client in the process of sending the first live media stream to the client C1, the proxy client also needs to adjust the timestamp of the first live media stream, so that the adjusted timestamp satisfies: the proxy client sends to the client C1
  • the time stamp of the first frame of the first live media stream is 0, and the time stamps of adjacent frames of the first live media stream sent to the client C1 are continuous.
  • the “continuous” means that the time interval between adjacent video frames of the first live media stream received by the client C1 is the same, where the time interval is the reciprocal of the frame rate f.
  • the following describes how the client C2 enters the live broadcast room and obtains the live media stream. Specifically include the following steps:
  • Client C2 sends an accessible media server request message to the Web server in RDC.
  • the request message includes the user name, IP address, live broadcast room name of client C2, and the secret obtained by client C2 after being authenticated. Key Token and other information.
  • the client C2 forwards the request message to the Web server in the RDC through the proxy client and the proxy server, and during the forwarding process, both the proxy client and the proxy server obtain the information carried in the request message.
  • the Web server in the RDC receives the request message, and sends a response message to the client C2, where the response message is used to inform the client C2 of the media servers it can access.
  • the Web server selects one of the multiple media servers to provide media streaming services for the client C2, and sends relevant information of the selected media server, such as the URL information, IP address, and port of the media server The number, etc. are sent to the proxy server and the proxy client through the response message.
  • the proxy client and the proxy server obtain the information carried in the request message, including the information of the media server that the client C2 can access. For example, the IP address and port number of the media server.
  • the client C2 sends a second live room request message for requesting to enter the live room to the proxy client, where the second live room request message indicates that the client C2 requests to enter the live room.
  • the second live broadcast room request message includes the user name, IP address, port number, live broadcast room name, and Token obtained after authentication of the client C2.
  • the proxy client receives the second live room request message sent by the client C2, and sets the role of the client C2 to a working state. At the same time, add a record about client C2 in the "live room user relationship table". Specifically, the recorded content includes: client C2's IP address, port number, user status, user name, and target media server selected in RDC The IP address and port number, the name of the live broadcast room and other information. Among them, the user status of the client C2 is working. The IP address of the client C2 may be the primary key stored in the database.
  • the proxy client adds its own identifier to the second live broadcast room request message, and the identifier of the proxy client is the IP address or port number of the proxy client.
  • the proxy client sends the second live room request message added with the proxy client identifier to the proxy server.
  • the modified second live room request message includes information such as the identifier of the proxy client, the user name of the client C2, the name of the live room, and the token obtained after authentication.
  • the proxy server receives the modified second live room request message sent by the proxy client, determines the role of the client C2 according to the second live room request message, and refreshes the user relationship table in the live room. Specifically, one possible implementation is that after receiving the second live broadcast room request message, the proxy server determines whether there is a role of the main user who enters the live broadcast room through the proxy client in the current live broadcast room. The client, if it exists, determines that the role of the client C2 is a servant user. In this embodiment, the role of the client C1 already exists in the current live broadcast room as the client of the master user, so it is determined that the role of the client C2 is the servant user.
  • S25 also includes that the proxy server refreshes the "user relationship table in the live broadcast room" and identifies the role of the client C2 as a slave. In addition, it also includes: the proxy server adds the identification of the proxy client, such as the IP address and port number of the proxy client, to the record of the client C2.
  • the proxy server sends the second live room request message to the media server in the RDC.
  • the second live broadcast room request message does not include the identifier of the proxy client.
  • the media server receives the second live room request message, and sends a second live room response message to the client C2, where the second live room response message is used to notify the client C2 that it has successfully entered the live room. Specifically, the media server passes the second live room response message through the proxy server and the proxy client, and then the proxy client forwards the second live room response message to the client C2.
  • the client C2 sends a second media request message to the proxy client, where the second media request message is used to request the media server to obtain the live media stream.
  • a second identifier of the client C2 carried in the second media request message and the second identifier is used to uniquely identify the client C2.
  • the second identifier includes the client C2's IP address and user name, etc.
  • the proxy client forwards it to the proxy server, and the proxy server sends the second media request message to the media server in the RDC.
  • the media server After receiving the second media request message, the media server sends a second media response message to the client C2, where the second media response message is used to notify the client C2 that the first live media stream is allowed to be obtained. Specifically, the media server sends the second media response message to the proxy server, then the proxy server forwards the second media response message to the proxy client, and finally the proxy client forwards the second media response message to the client C2.
  • the proxy client sends the locally cached first live media stream to the client C2. Further, when sending the first live media stream, the time stamp of the first live media stream is adjusted so that the adjusted time stamp is It is satisfied that the time stamp of the first frame of the first live media stream sent by the proxy client to the client C2 is 0, and the time stamps of adjacent frames of the first live media stream sent to the client C2 are continuous.
  • the media server sends a second live media stream to the proxy server.
  • the second live media stream is a media stream sent to the client C2, and the role of the client C2 is a servant user.
  • the proxy server After receiving the second live media stream, the proxy server does not cache or forward the second live media stream to the client C2, because the second live media stream is a media stream sent to the client C2 of the servant user.
  • S33 The media server sends the first live media stream to the proxy server in real time.
  • the proxy server receives the first live media stream sent by the media server, and caches the fragments of the first live media stream locally in GOP units.
  • the proxy server locally caches 3 GOPs, and can also cache more or fewer GOPs, which is not limited in this embodiment.
  • S35 The proxy server sends the first live media stream to the proxy client.
  • the proxy client receives the first live media stream, and caches the first live media stream segment locally in a GOP unit.
  • the proxy client determines the number of clients of the master user and the servant user in the live room according to the content recorded in the "live room user relationship table", and copies the cached first live media stream segment to prepare for sending to the live room In the client.
  • client C1 and client C2 there are only two clients in the current live broadcast room, client C1 and client C2, where client C1 is the main user and client C2 is the servant user, so the proxy client copies the first live media stream , To prepare to send to client C2.
  • the proxy client sends the locally cached first live media stream to the client C1.
  • the proxy client adjusts the time stamp in the first live media stream according to the time when the client C1 receives the video frame of the media stream.
  • the proxy client sends the locally cached first live media stream to the client C2.
  • the proxy client adjusts the time stamp in the first live media stream according to the time when the client C2 receives the video frame of the media stream.
  • the proxy client adjusts the timestamp of the video frame watched by the user entering the live broadcast room, so that the client C1 and the client C2 in the live broadcast room can watch the media content of the first live broadcast "synchronously", thereby improving user experience.
  • the proxy client and the proxy server are used to obtain the live media stream requested by the first client of the main user, some of the live media stream fragments are cached locally at the proxy client.
  • the proxy client When the second client enters the live broadcast room When requesting a live media stream, the proxy client directly sends the locally cached live media stream to the second client, thereby avoiding the proxy server from sending the live media stream to the proxy client.
  • the proxy server in this method only needs to send one Sending a live media stream to the proxy client only needs a wide area bandwidth to transmit the live media stream, which can effectively reduce the flow of sending media streams, reduce the load on the WAN network link, and save resource overhead.
  • the method of this embodiment can also combine the first live room request message and the first media request message of the client C1 into one message, and the combined message has the first live room request message and the first media.
  • the request message has two functions.
  • the proxy server can count the total number of clients currently entering the live broadcast room with the role of the main user according to the number of first media request messages.
  • the second live room request message and the second media request message of the client C2 can also be combined into one message, and the corresponding method for determining the role of the client C2 is also the same, which will not be repeated in this embodiment.
  • the method provided in this embodiment also includes: when the role of the client C2 changes, for example, the servant user role is changed to the master user, and the media server continues to send the live media stream to the client C2. Further, as shown in Figure 6, including S40 to S53, the specific method flow is as follows:
  • the client C1 sends a request message for exiting the live broadcast room to the proxy client, where the request message for exiting the live broadcast room is used to request the client C1 to exit the live broadcast room.
  • the request message for exiting the live broadcast room includes the user name, IP address, port number, user role, and name of the live broadcast room of the client C1.
  • the proxy client After receiving the request message for exiting the live broadcast room, the proxy client marks the role of the client C1 as an exiting user, and records it in the "live room user relationship table".
  • S42 The proxy client sends the request message for exiting the live broadcast room to the proxy server.
  • the proxy server receives the request message for exiting the live broadcast room, and does not forward the request message for exiting the live broadcast room to the media server for the time being, because at this time the first live media stream requested by the client C1 as the main user is being watched by the client C2 .
  • the role of the client C1 is marked as an exiting user, and is recorded in the "live room user relationship table".
  • the proxy server selects one of the clients in the live broadcast room as the new primary user.
  • the only clients that enter the live broadcast room through the proxy client are clients C1 and C2, and when the client C1 When requesting to exit the live broadcast room, select client C2 as the new master user, and change the role of client C2 from the servant user to the master user, and mark it as the slave-to-master user.
  • the media server sends the second live media stream to the proxy server in real time.
  • the content of the second live media stream is the same as the content of the first live media stream, and both come from the content source.
  • the proxy server receives the second live media stream, and caches the second live media stream locally in a GOP unit.
  • the method further includes: the proxy server uses an alignment algorithm to align the first live media stream and the second live media stream.
  • the process includes: each time the proxy server receives an I frame of the first live media stream, it compares the I frame with the locally buffered I frame of the second live media stream, and every time the second live media stream is received Compare the I frame with the locally buffered I frame of the first live media stream, if the above comparison process finds the I frames that belong to the first live media stream and the second live media stream and have the same media content (Hereinafter referred to as I frame a and I frame b respectively), it is determined that the two live media streams are aligned. It can be understood that the I frame a and the I frame b are the same video frame.
  • switching frame x determines the last frame of the first live media stream sent to the proxy client (hereinafter referred to as switching frame x) and the second live broadcast sent to the proxy client
  • the first frame of the media stream (hereinafter referred to as switching frame y), switching frame x and switching frame y are adjacent frames.
  • the nth frame after I frame a in the first live media stream may be determined as the switching frame x
  • the n+1th frame after I frame b in the second live media stream may be determined as the switching frame y, where n is An integer greater than or equal to 0. Since I frame a and I frame b are the same video frames, the nth frame after I frame a and the n+1th frame after I frame b are naturally adjacent frames.
  • the client C2 of the new primary user is used to request and obtain the second live media stream, and align the first live media stream and the second live media stream
  • the proxy server sends the second live media stream to the proxy client, the proxy server seamlessly connects the media content of the first live media stream that was originally playing, avoiding the problem of the proxy server switching the live media stream.
  • video content has the effect of repeated or less playback.
  • the proxy server sends the request message for exiting the live broadcast room to the media server.
  • the media server After receiving the request message for exiting the live broadcast room, the media server sends a response message for exiting the live broadcast room to the proxy server, where the exiting live broadcast room response message is used to notify the client C1 that the exit is successful.
  • the proxy server deletes the record corresponding to the client C1 from the "user relationship table between live broadcasts".
  • the proxy server receives the response message for exiting the live broadcast room sent by the media server, and forwards the response message for exiting the live broadcast room to the proxy client.
  • the proxy client receives the exit live room response message sent by the proxy server, and deletes the record corresponding to the client C1 from the "live room user relationship table".
  • S52 The proxy client sends the response message for exiting the live broadcast room to the client C1.
  • it also includes: sending the second live media stream buffered by the proxy server to the proxy client, and the proxy client receives the second live media stream and caches it locally in units of GOP, and then caches the second live media stream segment. Sent to the client C2 to ensure that the client C2 in the live broadcast room can watch the live media content normally.
  • the proxy client sends the second live media stream to the client C2, it adjusts the time stamp of the second live media stream so that the time stamp of the first frame of the second live media stream received by the client C2 It is continuous with the time stamp of the last frame of the first live media stream, and the corresponding time interval is the reciprocal of the frame rate parameter f.
  • the proxy server selects a new client from the live broadcast room as the new main user, aligns the live media stream of the new main user and sends it to the agent Client.
  • the proxy client receives the live media stream of the new main user sent by the proxy server, it adjusts the timestamp of the live media stream, so that other users in the live room watching the media content have no perception of the media stream switching. This method guarantees The viewing experience of users in the live broadcast room.
  • This embodiment provides another method for sending live media streams.
  • the method is applied to a technical scenario of multiple primary user roles, where the multiple primary users refer to the number of clients of the primary user role set in the live room being greater than or equal to 2. Further, it includes a primary master user, which can be identified as a main master user, and multiple backup master users, which can be identified as a secondary master user, and at least one role is a slave user.
  • the process of requesting and obtaining the live media stream for the client that enters the live room through the same proxy client is similar to that of the previous embodiment, but the differences include: the identification of the client's role and when there is a master When the client of the user role exits the live broadcast room, the identity of the client's role and the live media stream are copied and distributed still in the live broadcast room.
  • this embodiment also includes a third client (hereinafter referred to as "client C3"), and the preset upper limit of the number of main user roles in the live broadcast room is set to 2.
  • client C3 a third client
  • each client The process of entering the live room and requesting the live media stream: as shown in Figure 7, including the following:
  • S1 to S18 are processes for the client C1 to enter the live broadcast room and request to obtain the live media stream.
  • the process is the same as S1 to S18 in the first embodiment, except that when the "live room user relationship table" is refreshed in S9, the role flag of the client C1 is set as the main-master.
  • the role flag of the client C1 is set as the main-master.
  • the proxy server obtains the first live media stream sent by the media server
  • the 3 first live media stream fragments are cached locally in GOP units, and the first live media stream fragments are sent to the client through the proxy client in real time End C1.
  • S19 to S39 are processes for the client C2 to enter the live broadcast room and request to obtain the live media stream. Specifically, it includes: S19 to S24, which is a process in which the client C2 enters the live broadcast room through the proxy client and sends a second live broadcast request message to the proxy client. The process is the same as S19 to S24 in the first embodiment, so it can Please refer to the specific description of the first embodiment above, which will not be repeated here.
  • the proxy server After receiving the second live room request message sent by the proxy client, the proxy server determines the role of the client C2 according to the second live room request message. Specifically, it is determined whether the number of clients that enter the live broadcast room through the proxy client and the role of the master user when obtaining the second live room request message reaches a preset upper limit, and if the preset upper limit is reached, it is determined that client C2 is a servant User; if the preset upper limit is not reached and the number of clients of the primary user is not 0, it is determined that the client C2 is the backup primary user.
  • the preset upper limit is 2, and the proxy server determines that two live room request messages are currently obtained, which are the first live room request message from client C1 and the second live room request message from client C2. , And the role of the client C1 is the main primary user. At this time, the number of primary users in the live broadcast room is 1, which has not reached the preset upper limit, so the proxy server determines that the role of the client C2 is the backup primary user.
  • it also includes refreshing the record about the client C2 in the "user relationship table between live broadcasts", and marking the role of the client C2 as the backup master user.
  • S26 to S39 It also includes: S26 to S39, a process for the client C2 to obtain the first live media stream sent by the proxy client, and a process for the proxy client to send the first live media stream to the client C1.
  • This process is the same as the embodiment S26 to S39 in No. 1 are the same, so this embodiment will not repeat them in detail.
  • the proxy server obtains the second live media stream from the media server
  • the second live media stream is the media stream sent to the client C2
  • the role of the client C2 is the backup master user.
  • the proxy server caches the second live media stream locally in GOP units, and uses an alignment algorithm to align the first live media stream and the second live media stream.
  • the process of aligning the first live media stream and the second live media stream by the proxy server using an alignment algorithm includes: each time an I frame of the first live media stream is received by the proxy server, the I frame is combined with the locally cached I frame.
  • the I frames of the second live media stream are compared, and every time an I frame of the second live media stream is received, the I frame is compared with the locally buffered I frame of the first live media stream. If the above comparison process is passed I frames that belong to the first live media stream and the second live media stream and have the same media content are found (hereinafter referred to as I frame a and I frame b respectively), and it is determined that the two live media streams are aligned.
  • I frame a and the I frame b are the same video frame. Then determine the switching point according to I frame a and I frame b, that is, determine the last frame of the first live media stream sent to client C2 (hereinafter referred to as switching frame x) and the second live media sent to each client C2
  • the first frame of the stream hereinafter referred to as switching frame y
  • switching frame x and switching frame y are adjacent frames.
  • the nth frame after I frame a in the first live media stream may be determined as the switching frame x
  • the n+1th frame after I frame b in the second live media stream may be determined as the switching frame y, where n is An integer greater than or equal to 0, since the I frame a and the I frame b are the same video frame, the nth frame after the I frame a and the n+1th frame after the I frame b are naturally adjacent frames.
  • the proxy server locally caches the second live media stream on the proxy server for subsequent use.
  • the client C3 enters the live room and requests and obtains the live media stream, which specifically includes:
  • the client C3 sends a request message of an accessible media server to the Web server in the RDC. Further, the request message includes: the user name, IP address, live room name of the client C3, the key Token obtained by the client C3 after authentication, and other information, where the IP address is used to determine the location of the client C3 .
  • the Web server in the RDC receives the request message, and sends a response message of an accessible media server to the client C3, where the response message is used to inform the client C3 of the media server it can access.
  • the Web server in the RDC sends the response message to the proxy server, the proxy server sends the response message to the proxy client, and the proxy client forwards the response message to the client C3.
  • the Web server determines the location of the client C3 according to the IP address carried in the request message for accessing the media server sent by the client C3, and selects the media server that is closer to the client C3 as the target media according to the location information server.
  • the response message carries relevant information of the target media server, such as URL information, IP address, and port number of the target media server. Therefore, the proxy server and the proxy client obtain the client when forwarding the response message.
  • the client C3 sends a third live room request message for requesting to enter the live room to the proxy client.
  • the third live room request message indicates that the client C3 requests to enter the live room.
  • the third live broadcast room request message includes the user name, IP address, port number, live broadcast room name, and Token obtained after authentication of the client C3.
  • the proxy client receives the third live room request message, and sets the client C3 role to a working state.
  • update the "user relationship table in the live broadcast room” add a record about the client C3 in the user relationship table in the live broadcast room.
  • the recorded content includes: the IP address of the client C3, port number, user status, user name, The IP address and port number of the target media server selected in RDC, the name of the live broadcast room, and other information. Among them, the user status of the client C3 is working.
  • the record also includes the identification of the proxy client, such as the IP address and port number of the proxy client.
  • the proxy client adds its own identifier to the third live broadcast room request message, and the identifier of the proxy client is the IP address or port number of the proxy client.
  • the proxy client sends the third live room request message with the proxy client identifier added to the proxy server, where the modified third live room request message includes: the proxy client's identifier, the client The user name of the terminal C3, the name of the live broadcast room, and the token obtained after authentication.
  • the proxy server receives the modified third live room request message, determines the role of the client C3 according to the third request message, and refreshes the user relationship table in the live room. Specifically, determining the role of the client C3 includes: determining whether the number of primary users entering the live broadcast room through the proxy client reaches a preset upper limit when the third live broadcast room request message is received, and if it reaches , It is determined that the role of the client C3 is a servant user; if the preset upper limit is not reached and the number of master users is not 0, the role of the client C3 is determined to be the backup master user. In this embodiment, the preset upper limit is 2. When the client C3 enters the live broadcast room through the proxy client, the number of clients of the current master user is 2, which is equal to the preset upper limit, so it is determined that the role of the client C3 is Servant user.
  • the proxy server refreshes the "user relationship table in the live broadcast room", marking the role of the client C3 as a servant user.
  • the proxy server sends the third live broadcast room request message to the media server in the RDC.
  • the third live broadcast room request message does not include the identifier of the proxy client.
  • the media server in the RDC receives the third live room request message, and sends a third live room response message to the client C3, where the third live room response message is used to notify the client C3 that it has successfully entered the live room. Specifically, the media server first sends the third live room response message to the proxy server, and then the proxy server sends the third live room response message to the proxy client, and finally the proxy client sends the third live broadcast The response message is forwarded to the client C3.
  • the client C3 sends a third media request message, where the third media request message is used to request the media server to obtain the live media stream.
  • the identifier of the client C3 carried in the third media request message is used to uniquely identify the client C3.
  • the identifier includes the IP address of the client C3 and the user Name etc.
  • the media server After receiving the third media request message, the media server sends a third media response message to the client C3, where the third media response message is used to notify the client C3 that the live media stream is allowed to be obtained. Specifically, the media server forwards the third media response message to the client C3 through the proxy server and the proxy client.
  • the proxy client sends the locally cached first live media stream to the client C3. Wherein, before sending the first live media stream, the proxy client also needs to adjust the timestamp of the first live media stream, so that the client C3 receives the first frame of the first live media stream. The timestamp is 0, and the timestamps of adjacent frames of the first live media stream sent to the client C3 are continuous.
  • the media server sends a third live media stream to the proxy server, the third live media stream originates from a content source, and the third live media stream is a media stream sent to the client C3.
  • the proxy server After receiving the third live media stream, the proxy server does not cache or forward the third live media stream, because the role of the client C3 is a servant user.
  • the proxy server receives the first live media stream sent by the media server in real time.
  • the proxy server caches the first live media stream locally in the unit of GOP. Among them, the proxy server only caches several latest GOPs locally.
  • the proxy server sends the cached first live media stream to the proxy client.
  • the proxy client caches the first live media stream locally in a GOP unit.
  • S58 The proxy client copies the first live media stream according to the user relationship table between the live broadcasts.
  • the proxy client in addition to the client C1 of the main main user, there are also backup main user client C2 and servant user client C3. So make two copies of the first live media stream.
  • the proxy client sends the first live media stream to the client C1.
  • the proxy client adjusts the timestamp of the first live media stream according to the play time of the client C1.
  • the proxy client sends the first live media stream to the client C2.
  • it also includes: the proxy client adjusting the time stamp of the first live media stream according to the playing time of the client C2.
  • the proxy client sends the first live media stream to the client C3.
  • it also includes: the proxy client adjusting the timestamp of the first live media stream according to the playing time of the client C3.
  • this embodiment also includes the main main client C1 exiting the live broadcast room process, which is similar to the flow of the client C1 exiting the live broadcast room in the previous example, specifically, as shown in FIG. 8.
  • S62 to S65 are the same as S40 to S43 in the first embodiment.
  • the proxy server selects the backup primary user client C2 as the new primary primary user, and changes the role of the client C2 from the backup primary user to the primary primary user, and at the same time updates the client C2 in the "live room user relationship table" recording.
  • S67 to S73 are the same as S48 to S53 in the first embodiment.
  • the media server sends a third live media stream to the proxy server.
  • the third live media stream is a media stream sent to the client C3 and originated from the content source. At this time, the role of the client C3 is changed from a servant user to Backup the main user.
  • the proxy server switches the first live media stream sent to the client in the live broadcast room (such as client C2) to the second live media stream, and the media server continues to send the media server through the proxy server.
  • the client C2 sends the second live media stream, and after switching, the proxy server distributes the second live media stream continuously received to the proxy client. For details, see the subsequent steps.
  • the media server sends a second live media stream to the proxy server in real time.
  • the second live media stream is the media stream sent to the client C2, and the source is the content source.
  • the role of the client C2 is from the backup
  • the main user is changed to the main main user.
  • the proxy server After receiving the second live media stream, the proxy server locally caches the second live media stream in units of GOPs, and uses an alignment algorithm to align the first live media stream and the second live media stream .
  • S78 The proxy server sends the second live media stream to the proxy client.
  • the proxy client After receiving the second live media stream sent by the proxy server, the proxy client locally caches the second live media stream in units of GOPs.
  • S80 The proxy client copies and distributes the second live media stream according to the "user relationship table in the live broadcast room".
  • the second live media stream is copied and is ready to be sent to the role of the backup master in the live broadcast room.
  • the proxy client sends the locally cached second live media stream to the client C2.
  • the proxy client adjusts the time stamp in the second live media stream according to the time when the client C2 receives the video frame of the media stream.
  • the proxy client sends the locally cached second live media stream to the client C3.
  • the proxy client adjusts the time stamp in the second live media stream according to the time when the client C3 receives the video frame of the media stream.
  • the proxy server when the client C1 of the main main user exits the live broadcast room, the proxy server sends the live media stream of the client C2 of the new main main user to the proxy client, and the proxy client sends the new live media stream to the proxy client.
  • the live broadcast media stream is sent to the clients C2 and C3, so as to ensure that when the main main user in the live room exits, the viewing experience of other users in the live room is not affected.
  • the proxy server obtains multiple live media streams sent by the media server, and each live media stream corresponds to a media request message from a client.
  • the proxy server sends media streams to the proxy client, it only sets the role as the main master.
  • a copy of the live media stream corresponding to the user's client is sent to the proxy client.
  • the obtained live media stream whose role is the backup master user is cached locally on the proxy server, and the obtained live media stream of the servant user is not cached and directly discarded , So that the proxy server only consumes a portion of bandwidth to transmit the live media stream to the proxy client, saving the WAN network resources between the proxy server and the proxy client.
  • the proxy client copies and distributes the live media stream to all clients in the live room, and adjusts the time of each client before sending the live media stream Poke so that all users who enter the live broadcast room through the proxy client can watch the live broadcast content at the same time.
  • the method provided in this embodiment also includes the client C2 and the client C1 requesting to exit the live broadcast room at the same time.
  • the process of the client C2 requesting to exit the live broadcast room is similar to the aforementioned method for the client C1 to exit the live broadcast room.
  • the process is the same as the aforementioned S62 to S73 (as shown in FIG. 8), and will not be described in detail.
  • the role of the client C2 is changed from the backup master user to the main master user
  • the role of the client C3 is changed from the servant user to the backup master user.
  • S73 is the process of client C2 requesting and exiting the live broadcast room, which specifically includes: client C2 sends a request message for exiting the live broadcast room to the proxy client, and the proxy client marks the role of client C2 as the exit user after receiving it, and forwards it.
  • the request message for exiting the live broadcast room is sent to the proxy server, and the proxy server refreshes the role of the client C2 as the exit user in the "user relationship table in the live broadcast room" after receiving it.
  • the client C3 is still in the live room and obtains the live media stream, and the proxy server receives the third live media stream sent by the media server.
  • the third live media stream is the media stream sent to the client C3.
  • the role of the client C3 is changed from the backup primary user to the primary primary user, so the proxy server locally caches the third live media stream in units of GOPs.
  • the proxy server Since the client C3 in the live room is still watching live content, the proxy server needs to switch the live media stream to the third live media stream, and align the third live media stream with the first live media stream.
  • the proxy server sends the third live media stream to the proxy client.
  • the proxy client After receiving the third live media stream, the proxy client caches and sends the third live media stream to the client C3, and then The proxy client adjusts the timestamp when sending the third live media stream, so that the third live media stream sent to the client C3 can be seamlessly connected to the previous media stream, so that the clients C1 and C2 are C3 has no impact, thus ensuring the smoothness of watching media content at the client C3 still in the live broadcast room.
  • It also includes: when forwarding the response message of the client C2 to exit the live broadcast room, the proxy server and the proxy client delete the record about the client C2 in the "live room user relationship table" so as to update the client information in the live broadcast room in real time.
  • Embodiment 1 and Embodiment 2 are for all clients that enter the live broadcast room through the same proxy client, the proxy server identifies the role of each client and distributes the live media stream.
  • the proxy server identifies the role of each client and distributes the live media stream.
  • multiple proxy clients access the same proxy server.
  • the proxy server enters the live broadcast room through multiple proxy clients All the clients of, identify the user role uniformly. For example, in the case of three proxy clients accessing the same proxy server, for all clients in the live broadcast room, uniformly identify the master user and the servant user, and according to the identified role , To send the live media stream to the proxy client.
  • the proxy server identifies the user role and sends the live media stream to each proxy client, and the process of each proxy client copying and distributing the live media stream to all the clients it accesses is the same as the foregoing first embodiment and embodiment. The two methods are the same, so I won't repeat them here.
  • the video live broadcast bilateral proxy technology utilizes a proxy client and a proxy server, where the proxy server is used to identify the role of each client according to the live room request message, and only send a copy of the live media stream with the main user role
  • the proxy client receives the live media stream of the main user and then copies and distributes it to all clients that it accesses.
  • This method effectively reduces the traffic of sending media streams between the proxy server and the proxy client, and reduces The export bandwidth is saved, and the resource cost of the WAN network is saved.
  • this method does not require the media server to configure a separate authentication to the client, and directly forwards it uniformly through the proxy client, so the operation and maintenance cost is further reduced.
  • FIG. 9 is a schematic structural diagram of a media stream sending apparatus provided by an embodiment of this application.
  • the apparatus may be the proxy server described in the foregoing embodiment, or may also be a proxy client.
  • the device includes a receiving unit 901, a processing unit 902, and a sending unit 903, and may also include other functional modules or units, such as a storage unit.
  • the device may be a server, configured to execute the media stream sending method described in the foregoing embodiment, for example, to provide live media streams for at least two clients that enter the live broadcast room through the same proxy client.
  • the receiving unit 901 is configured to respectively receive a first live room request message and a second live room request message sent from the same proxy client for requesting to enter the live room, where the The first live broadcast room request message comes from the first client, and the second live broadcast room request message comes from the second client; the receiving unit 901 is further configured to respectively receive the media server sent to the first client through the proxy server The first live media stream and the second live media stream sent to the second client; the processing unit 902 is configured to determine the role of the first client according to the first live room request message, and according to the second The live broadcast room request message determines the role of the second client; the sending unit 903 is configured to, when it is determined that the role of the first client is the master user and the role of the second client is the servant user, only the second client A live media stream is sent to the first client and the second client.
  • the processing unit 902 is further configured to request according to the first live room The identifier of the proxy client included in the message, and the identifier of the proxy client included in the second live room request message, it is determined that the first live room request message and the second live room request message are from the same agent Client.
  • the processing unit 902 is specifically configured to determine whether there is a proxy client in the live broadcast room when the second live broadcast room request message is received.
  • the role entering the live broadcast room is the client of the master user; if it exists, it is determined that the role of the second client is the servant user. Conversely, if the live broadcast room does not exist, it is determined that the role of the second client is the main user.
  • the receiving unit 901 is further configured to receive the exit live room sent by the proxy client after sending the first live media stream to the proxy client Request message, the request message for exiting the live broadcast room is used to request the first client to exit the live broadcast room; the processing unit 902 is also used to set the second client as the new primary user The role of the second client is changed from the servant user to the master user, and the first live media stream sent to the second client is switched to the second live media stream.
  • the processing unit 902 is further configured to identify according to the first live media stream and the second live media stream that they belong to the first live media stream and all The first I frame and the second I frame of the second live media stream, the first I frame and the second I frame are the same video frame; determined according to the first I frame and the second I frame The first switching frame and the second switching frame that are adjacent and belong to the first live media stream and the second live media stream respectively, and use the first switching frame and the second switching frame as the direction The last frame of the first live media stream sent by the second client and the first frame of the second live media stream sent to the first client; the sending unit 903 is further configured to determine After the first switching frame and the second switching frame, they are also used to forward the request message for exiting the live broadcast room of the first client to the media server.
  • the processing unit 902 is specifically configured to determine whether to enter the live broadcast room through the proxy client when the second live broadcast room request message is received. Whether the number of clients in the role of the master user reaches a preset upper limit, the preset upper limit is greater than or equal to 2; if the preset upper limit is reached, it is determined that the role of the second client is a servant user.
  • the processing unit 902 determines that the role of the second client is the backup primary user.
  • the receiving unit 901 is further configured to receive A request message for exiting the live broadcast room from the first client;
  • the processing unit 902 is further configured to change the role of the second client from the servant user when it is determined to use the second client as the new backup master user It is the backup main user;
  • the storage unit is used to buffer the received second live media stream in a GOP unit.
  • the storage unit also uses The received second live media stream is buffered in GOP units; the processing unit 902 is further configured to identify according to the first live media stream and the buffered second live media stream that they belong to the first live broadcast.
  • the receiving unit 901 is further configured to receive a request message for exiting the live broadcast room from the first client; the processing unit 902 is further configured to: When the second client is the new main user, and, according to the first I frame and the second I frame, determine adjacent ones that belong to the first live media stream and the second live media stream respectively A first switching frame and a second switching frame; switching the first live media stream sent to the second client to the second live media stream according to the first switching frame and the second switching frame; wherein , The last frame of the first live media stream sent to the second client is the first switching frame, and the first frame of the second live media stream sent to the first client is The second switching frame.
  • the storage unit is configured to cache the first live media stream and the second live media stream in units of GOPs.
  • the receiving unit 901 is configured to respectively receive the first live room request message sent by the first client and the second live room request message sent by the second client; the sending unit 903 Is configured to send the first live room request message and the second live room request message to the media server through a proxy server; the receiving unit 901 is further configured to receive the first live media stream sent by the proxy server, the first The live media stream is a media stream sent by the media server to the first client through the proxy server.
  • the role of the first client is the master user, and the role of the second client is the servant user; the sending unit 903 also uses Send the first live media stream to the first client and the second client.
  • processing unit 902 is configured to add the identifier of the proxy client to the first live broadcast request message before sending the first live broadcast request message, and before sending the second live broadcast request message , Adding the identifier of the proxy client to the second live room request message.
  • the processing unit 902 is further configured to mark the role of the first client as a work when the first live broadcast request message is received; In the case of receiving the second live broadcast room request message, mark the role of the second client as work; in the case of receiving the exit live room request message, mark the role of the first client For exit.
  • the processing unit 902 is further configured to adjust the first live media stream before sending the first live media stream to the second client. So that the adjusted timestamp satisfies: the timestamp of the first frame of the first live media stream sent to the second client is 0, and all the timestamps sent to the second client The time stamps of adjacent frames of the first live media stream are continuous.
  • the receiving unit 901 is further configured to receive the second live media stream sent by the proxy server
  • the second live media stream is a media stream sent by the media server to a second client through the proxy client, and the second client is a client whose role is changed from a servant user to a master user; the sending unit 903 also Used to send the second live media stream to the second client.
  • the processing unit 902 is further configured to adjust the second live media stream before sending the second live media stream to the second client.
  • the time stamp of the stream so that the adjusted time stamp satisfies: the time stamp of the first frame of the second live media stream sent to the second client and the first frame sent to the second client
  • the time stamp of the last frame of the live media stream is continuous.
  • the present application also provides a network device, which may be the proxy server in the foregoing method embodiment, or the proxy client, or may also be the proxy server in the CDN system Other equipment or devices.
  • the network device includes: a transceiver 10, a processor 20, and a memory 30.
  • the network device may also include more or fewer components, or a combination of certain components, or a different component arrangement. This application does not Qualify.
  • the transceiver 10 is used to receive and send request messages, response messages, live media streams, etc., and perform data transmission with other devices (clients, media servers, etc.) in the network. Further, the transceiver 10 may include components such as a receiver 1001, a transmitter 1002, and an antenna 1003, or may also include a transceiver module. Further, the transceiver module may include a wireless local area network (WLAN) module, Bluetooth Communication modules such as modules, baseband modules, and radio frequency (RF) circuits corresponding to the communication modules are used for wireless local area network communication, Bluetooth communication, infrared communication and/or cellular communication system communication, For example, wideband code division multiple access (WCDMA) and/or high-speed downlink packet access (HSDPA). The transceiver module is used to control the communication of each component in the network device, and can support direct memory access (direct memory access).
  • WLAN wireless local area network
  • Bluetooth Communication modules such as modules, baseband modules, and radio frequency (RF) circuits corresponding to the communication modules are
  • the processor 20 is the control center of the network device, which uses various interfaces and lines to connect various parts of the entire device, and by running or executing software programs and/or units stored in the memory 30, and calling data stored in the memory 30, To perform various functions and various functions of network devices and/or process data.
  • the processor 20 can be composed of an integrated circuit (Integrated Circuit, IC), for example, can be composed of a single packaged IC, or can be composed of multiple packaged ICs with the same function or different functions.
  • IC integrated Circuit
  • the processor may only include a central processing unit (CPU), or it may be a GPU, a digital signal processor (Digital Signal Processor, DSP), and a control chip (such as a baseband chip) in the transceiver. combination.
  • CPU central processing unit
  • DSP Digital Signal Processor
  • control chip such as a baseband chip
  • the memory 30 may include a volatile memory (volatile memory), such as random access memory (Random Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as flash memory (flash memory), Hard disk (Hard Sisk Drive, HDD) or solid-state hard disk (Solid-State Drive, SSD); the storage may also include a combination of the above types of storage.
  • volatile memory such as random access memory (Random Access Memory, RAM
  • non-volatile memory such as flash memory (flash memory), Hard disk (Hard Sisk Drive, HDD) or solid-state hard disk (Solid-State Drive, SSD); the storage may also include a combination of the above types of storage.
  • a program or code may be stored in the memory, and the processor 802 may implement the function of the communication device by executing the program or code.
  • the functions of the receiving unit 901 and the sending unit 903 in the device embodiment shown in FIG. 9 may be implemented by the transceiver 10, or controlled by the processor 20.
  • the transceiver 10 is implemented; the functions to be implemented by the processing unit 902 may be implemented by the processor 20, and the functions of the storage unit may be implemented by the memory 30.
  • the functions of the receiving unit 901 and the sending unit 903 in the device embodiment shown in FIG. 9 may be implemented by the transceiver 10, or implemented by the transceiver 10 controlled by the processor 20;
  • the functions to be implemented by the processing unit 902 may be implemented by the processor 20, and the functions of the storage unit may be implemented by the memory 30.
  • the embodiment of the present application also provides a media stream sending system.
  • the system includes the media stream sending device shown in FIG. 9 or the network device shown in FIG. 10 in the foregoing embodiment, and also includes multiple clients, RDC, EDC, and content source devices to implement the foregoing various embodiments.
  • Media streaming method includes the media stream sending device shown in FIG. 9 or the network device shown in FIG. 10 in the foregoing embodiment, and also includes multiple clients, RDC, EDC, and content source devices to implement the foregoing various embodiments.
  • Media streaming method includes the media stream sending device shown in FIG. 9 or the network device shown in FIG. 10 in the foregoing embodiment, and also includes multiple clients, RDC, EDC, and content source devices to implement the foregoing various embodiments.
  • the media stream sending system is a live video system, such as a CDN system.
  • the present application also provides a computer storage medium, wherein the computer storage medium may store a program, and the program may include some or all of the steps in each embodiment of the content sending method and content receiving method provided in the present application when the program is executed.
  • the storage medium can be a magnetic disk, an optical disc, a read-only storage memory ROM, or a random storage memory RAM.
  • all or part of it may be implemented by software, hardware, firmware or any combination thereof.
  • software it can be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions. When the computer loads and executes the computer program, all or part of the processes or functions described in the foregoing embodiments of the present application are generated.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a network node, computer, server, or data center. Transmission to another site, computer or server via wired or wireless means.
  • the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform.
  • the technical solutions in the embodiments of the present invention can be embodied in the form of software products, which can be stored in a storage medium, such as ROM/RAM. , Magnetic disks, optical disks, etc., including a number of instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments of the present invention.
  • plural means two or more than two.
  • words such as “first” and “second” are used to distinguish the same items or similar items with substantially the same function and effect. Those skilled in the art can understand that words such as “first” and “second” do not limit the quantity and order of execution, and words such as “first” and “second” do not limit the difference.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

公开了一种媒体流发送方法、装置、设备和系统,用于为进入直播间的客户端提供直播媒体流,所述方法包括:代理服务器分别接收同一代理客户端发送的第一直播间请求消息和第二直播间请求消息,分别接收媒体服务器通过代理服务器向第一客户端发送的第一直播媒体流和向第二客户端发送的第二直播媒体流,代理服务器在确定所述第一客户端的角色为主用户、第二客户端的角色为仆用户的情况下,仅将第一直播媒体流发送给代理客户端,以使代理客户端将该第一直播媒体流发送给第一客户端和第二客户端。本方法对于同一直播间的所有客户端,代理服务器只需要发送一份直播媒体流给代理客户端,耗费一份广域带宽,所以降低了WAN网链路的负载,减小资源开销。

Description

一种媒体流发送方法、装置、设备和系统 技术领域
本申请涉及视频播放领域,尤其是涉及一种媒体流发送方法、装置、设备和系统。
背景技术
视频观看包括直播和点播两种方式。其中,对于视频点播方式,用户在观看的时候,可以随时选择快进或者回退视频内容,而对于直播而言却不能选择。所谓直播,可以概括地理解为是将每一帧数据打上时序标签后,再进行流式传输的过程。具体地,采集装置比如摄像机、麦克风等源源不断地采集音视频信息,然后将这些信息经过编码、封包、推流等处理后,再经过分发网络进行传输,播放端不停地下载数据并按时序进行解码播放。视频直播整个流程可以分为采集、编码、推流、转码、分发、解码/渲染等一系列过程。
主流的互联网视频直播厂家一般采用单播传输协议来传输视频,所以对于N个用户正在观看视频,就会有N路视频流。此外,对于企业中开展的视频直播,要求在支持直播视频的同时还要支持演示文档共享和文字评论等功能,在企业直播的Web页面中一边显示视频内容,一边还要延时共享文档和文字评论内容,以满足用户需求,提升用户体验。
为了提升用户体验、节省骨干网络带宽,直播平台一般会部署直播内容分发网络(Content Delivery Network,CDN)。所述直播CDN是一个分布式的内容分发平台,支持多级架构,可以将用于缓存的服务器分层分级部署,进而为不同地域的用户提供就近服务。
在直播CDN分发音视频流的过程中,对于视频的推流和分流过程一般使用实时消息协议(Real Time Messaging Protocol,RTMP),或者称实时消息传输协议;对于分发过程则一般使用RTMP、HLS(HTTP Live Streaming)和超文本传输协议(Hyper Text Transfer Protocol,HTTP)-闪视频(Flash Video,FLV),简称“HTTP-FLV”三种协议。其中,HLS是苹果公司基于HTTP的流媒体传输协议,主要应用于iOS设备包括iPhone、iPad、iPod touch以及Mac OSX提供音视频直播服务和录制内容(点播)等服务。HLS的最大特点是:它并不是一次性请求完整的数据流,而是会在服务器端将流媒体数据切割成连续的时长较短的小文件,并通过索引文件按序访问小文件。客户端只要不停的按序播放从服务器接收到的这些小文件,就能实现播放音视频。
如图1所示,在直播CDN时,内容源(content source)将音视频媒体流通过RTMP发送给企业数据中心(Enterprise Data Center,EDC),其中EDC中包括Web服务器(Web server)和多个媒体服务器(Media server),EDC中的Web服务器负责响应客户端(PC)的直播观看请求,对用户进行鉴权,并且根据用户的位置就近分配一个媒体服务器来提供服务。该被选择的媒体服务器会根据预设策略将音视频的媒体流发送给下一级的区域数据中心(Region Data Center,RDC),RDC中的媒体服务器在接收到该媒体流(直播内容)之后,会再按照预设策略将其发送给下一级的位于机房(Server Room,SR)中的媒体服务器,最后由机房中的媒体服务器缓存上级的媒体服务器分发的媒体流(直播内容)并直接为用户提供直播服务。
在这个过程中,上一级RDC中的媒体服务器需要向直播间中每个请求获取媒体流的客户端发送直播媒体流,使得上一级的媒体服务器要向直播间里的每个用户都发送直播媒体流,当进入直播间的用户数量较多时,需要占用大量的广域网(wide area network,WAN)资源 来传输直播媒体流,导致网络开销较大。
发明内容
本申请实施例提供了一种媒体流发送方法、装置、设备和系统,用于减小媒体服务器向同一直播间的客户端发送媒体流的资源开销,具体地,本申请实施例公开了以下技术方案:
第一方面,本申请提供了一种媒体流发送方法,所述方法为进入直播间的客户端提供直播媒体流,所述方法包括:代理服务器分别接收同一代理客户端发送用于请求进入直播间的第一直播间请求消息和第二直播间请求消息,其中所述第一直播间请求消息来自第一客户端,所述第二直播间请求消息来自第二客户端;代理服务器分别接收媒体服务器通过所述代理服务器向所述第一客户端发送的第一直播媒体流和向所述第二客户端发送的第二直播媒体流;代理服务器根据所述第一直播间请求消息确定所述第一客户端的角色,并根据所述第二直播间请求消息确定所述第二客户端的角色;所述代理服务器在确定所述第一客户端的角色为主用户、所述第二客户端的角色为仆用户的情况下,仅将所述第一直播媒体流发送给所述代理客户端,以使所述代理客户端将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。
本方面提供的方法,对于仆用户角色的第二客户端,在请求获取直播媒体流时,代理客户端只需将缓存在本地的主用户角色的第一客户端请求的第一媒体流直接发送给该第二客户端,从而避免了代理服务器再向代理客户端发送直播媒体流,无需代理服务器为每个通过该代理客户端进入直播间的客户端发送直播媒体流,本方法减少了代理服务器与代理客户端之间发送媒体流的流量,有效地降低出口带宽,节约了资源开销。
结合第一方面,在第一方面的一种可能的实现方式中,所述第一直播间请求消息中包括代理客户端的标识,和,所述第二直播间请求消息中包括所述代理客户端的标识;所述方法还包括:代理服务器根据所述第一直播间请求消息包括的所述代理客户端的标识,和,所述第二直播间请求消息包括的所述代理客户端的标识,确定所述第一直播间请求消息和第二直播间请求消息来自同一代理客户端。本方面通过在第一直播间请求消息或第二直播间请求消息携带代理客户端的标识,使得代理服务器在转发消息和响应时能够确定接收端对象,便于消息收发。
结合第一方面,在第一方面的另一种可能的实现方式中,所述代理服务器根据所述第二直播间请求消息确定所述第二客户端的角色,包括:代理服务器确定在接收到所述第二直播间请求消息时,所述直播间中是否存在通过所述代理客户端进入所述直播间的角色为主用户的客户端;如果存在,则确定所述第二客户端的角色是仆用户。本实现方式中,对于单一主用户的技术场景,代理服务器只需判断直播间中是否存在主用户,即可以确定进入直播间的客户端的身份角色,能够快速地识别出客户端的角色,并进行标记。
对应地,如果不存在所述主用户的客户端,则确定所述第二客户端的角色是主用户。
结合第一方面,在第一方面的又一种可能的实现方式中,所述代理服务器将所述第一直播媒体流发送给所述代理客户端之后,还包括:所述代理服务器接收代理客户端发送的退出直播间请求消息,所述退出直播间请求消息用于请求所述第一客户端退出所述直播间;所述代理服务器在确定将所述第二客户端作为新的主用户时,将第二客户端的角色从所述仆用户变更为主用户;以及将向第二客户端发送的第一直播媒体流切换为第二直播媒体流。本实现方式中,当主用户身份的第一客户端退出直播间时,利用新的主用户角色的第二客户端身份向媒体服务器请求并获取直播媒体流,从而保证仍然在直播间中的第二客户端观看媒体内容 不受影响,保证直播间中第二客户端的用户观看直播的用户体验。
结合第一方面,在第一方面的又一种可能的实现方式中,所述代理服务器向第二客户端发送的所述第一直播媒体流的最后一帧与向所述第二客户端发送的所述第二直播媒体流的第一帧为相邻帧;所述代理服务器将向所述第二客户端发送的第一直播媒体流切换为所述第二直播媒体流之前还包括:代理服务器根据所述第一直播媒体流和所述第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧。
所述代理服务器根据所述第一I帧和第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧,并将该第一切换帧和第二切换帧分别作为向所述第二客户端发送的所述第一直播媒体流的最后一帧,与,向所述第一客户端发送的所述第二直播媒体流的第一帧;代理服务器在确定所述第一切换帧和所述第二切换帧之后还包括:所述代理服务器将来自所述第一客户端的退出直播间请求消息转发给媒体服务器。
结合第一方面,在第一方面的又一种可能的实现方式中,代理服务器根据所述第二直播间请求消息确定第二客户端的角色,包括:所述代理服务器在接收到所述第二直播间请求消息时,判断通过所述代理客户端进入所述直播间的角色为主用户的客户端的数量是否达到预设上限,所述预设上限大于等于2且为正整数;如果达到所述预设上限,则确定所述第二客户端的角色是仆用户。本实现方式中,对于多个主用户的技术场景,即包括一个主要主用户和多个备份主用户的情况下,通过统计直播间中主用户角色的客户端数量与预设上限之间的大小来确定客户端的角色。可以理解地,还可以通过其他方式来确定客户端的角色,比如根据直播间请求的数量来确定,本实施例对此不予限制。
结合第一方面,在第一方面的又一种可能的实现方式中,如果所述直播间中角色为主用户的客户端的数量不为0,且没有达到所述预设上限,则代理服务器确定所述第二客户端的角色是备份主用户。
结合第一方面,在第一方面的又一种可能的实现方式中,在所述第一客户端是主要主用户,所述第二客户端是仆用户的情况下,还包括:所述代理服务器接收来自第一客户端的退出直播间请求消息;所述代理服务器在确定将所述第二客户端作为新的备份主用户时,将所述第二客户端的角色从仆用户变更为备份主用户;所述代理服务器以图像组GOP为单位缓存接收的所述第二直播媒体流。本实现方式,在第二客户端是备份主用户的情况下,代理服务器接收来自媒体服务器的第二直播媒体流,并存储在本地,以便为后续变更用户角色时为直播间的客户端提供该缓存的第二直播媒体流。
结合第一方面,在第一方面的又一种可能的实现方式中,在所述第一客户端是主要主用户,所述第二客户端是备份主用户的情况下,还包括:所述代理服务器以GOP为单位缓存接收的所述第二直播媒体流;根据所述第一直播媒体流和缓存的所述第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧。
结合第一方面,在第一方面的又一种可能的实现方式中,还包括:所述代理服务器接收来自所述第一客户端的退出直播间请求消息;在确定将所述第二客户端作为新的主要主用户时,将所述第二客户端的角色从所述备份主用户变更为主要主用户;所述代理服务器根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧;所述代理服务器根据所述第一切换帧和所述第二切换帧,将向第二客户端发送的第一直播媒体流切换为所述第二直播媒体流,其中,代理服务器向所述 第二客户端发送的所述第一直播媒体流的最后一帧为所述第一切换帧,向所述第一客户端发送的所述第二直播媒体流的第一帧为所述第二切换帧。本实现方式,在第二客户端的角色从备份主用户变更为主要主用户时,接收和缓存来自媒体服务器的第二直播媒体流,并将该缓存的第二直播媒体流复制分发给直播间中的所有客户端,从而保证直播间中其他客户端正常观看直播内容,不受影响。
结合第一方面,在第一方面的又一种可能的实现方式中,代理服务器以GOP为单位缓存所述第一直播媒体流和所述第二直播媒体流。可选的,在代理服务器本地缓存所述第一直播媒体流的3个GOP,和缓存第二直播媒体流的3个GOP。
第二方面,本申请实施例还提供了一种媒体流发送方法,所述方法为进入直播间的客户端提供直播媒体流,所述方法包括:代理客户端分别接收第一客户端发送用于请求进入直播间的第一直播间请求消息,和,第二客户端发送用于请求进入直播间的第二直播间请求消息,代理客户端通过代理服务器向媒体服务器发送所述第一直播间请求消息和所述第二直播间请求消息,代理客户端接收所述代理服务器发送的第一直播媒体流,所述第一直播媒体流是所述媒体服务器通过所述代理服务器向所述第一客户端发送的媒体流,所述第一客户端的角色为主用户,所述第二客户端的角色为仆用户,代理客户端将所述第一直播媒体流发送给所述第一客户端和第二客户端。
本方面提供的方法,由同一代理客户端接入直播间的所有用户而言,代理服务器只需要发送一份直播媒体流给代理客户端,即代理客户端只需耗费一份广域带宽来接收代理服务器发送的直播媒体流,相比于媒体服务器将所述直播媒体流发送给直播间中的各个客户端所占用的传输资源来说,降低了WAN网链路的负载,节约了传输开销。
结合第二方面,在第二方面的一种可能的实现方式中,所述代理客户端通过代理服务器向媒体服务器发送所述第一直播间请求消息之前还包括:所述代理客户端将所述代理客户端的标识添加到所述第一直播间请求消息中;和,所述代理客户端通过代理服务器向媒体服务器发送所述第二直播间请求消息之前还包括:所述代理客户端将所述代理客户端的标识添加到所述第二直播间请求消息中。
结合第二方面,在第二方面的另一种可能的实现方式中,所述代理客户端接收所述代理服务器发送的第一直播媒体流之后,还包括:所述代理客户端以图像组GOP为单位缓存所述第一直播媒体流。
结合第二方面,在第二方面的又一种可能的实现方式中,所述代理客户端将所述第一直播媒体流发送给所述第二客户端之前,还包括:代理客户端调整所述第一直播媒体流的时间戳,使得调整后的时间戳满足:代理客户端向第二客户端发送的所述第一直播媒体流的第一帧的时间戳为0,并且,向第二客户端发送的所述第一直播媒体流的相邻帧的时间戳连续。
结合第二方面,在第二方面的又一种可能的实现方式中,在所述第一客户端请求退出直播间的情况下,还包括:所述代理客户端接收所述代理服务器发送的第二直播媒体流,所述第二直播媒体流是媒体服务器通过所述代理客户端发送给第二客户端的媒体流,所述第二客户端是角色从仆用户变更为主用户的客户端;所述代理客户端将所述第二直播媒体流发送给所述第二客户端。
结合第二方面,在第二方面的又一种可能的实现方式中,所述代理客户端将所述第二直播媒体流发送给所述第二客户端之前,还包括:代理客户端调整所述第二直播媒体流的时间戳,使得调整后的时间戳满足:代理客户端向所述第二客户端发送的所述第二直播媒体流的第一帧的时间戳与向所述第二客户端发送的所述第一直播媒体流的最后一帧的时间戳连续。
第三方面,本申请实施例一种媒体流发送装置,所述装置包括:该装置包括用于执行上述第一方面以及第一方面的各种实现方式中方法步骤的单元。具体地,该装置包括接收单元、处理单元和发送单元,此外,还可以包括存储单元等其他模块或单元。
可选的,所述装置为代理服务器。
第四方面,本申请实施例一种媒体流发送装置,所述装置包括:该装置包括用于执行上述第二方面以及第二方面的各种实现方式中方法步骤的单元。具体地,该装置包括接收单元、处理单元和发送单元,此外,还可以包括存储单元等其他模块或单元。
可选的,所述装置为代理客户端。
第五方面,本申请实施例还提供了一种网络设备,包括收发器、处理器和存储器,所述处理器与所述存储器耦合,所述存储器用于存储指令;所述处理器用于调用所述指令使得所述网络设备执行前述第一方面以及第一方面各种实现方式中的媒体流发送方法,或者,调用所述指令使得所述网络设备执行前述第二方面以及第二方面各种实现方式中的媒体流发送方法。
可选的,所述网络设备为代理服务器,或,代理客户端。
进一步地,在本方面的一种可能实现方式中,当所述网络设备作为代理服务器时,所述收发器,用于分别接收同一代理客户端发送的用于请求进入直播间的第一直播间请求消息和第二直播间请求消息,分别接收媒体服务器通过所述代理服务器向所述第一客户端发送的第一直播媒体流和向所述第二客户端发送的第二直播媒体流,其中所述第一直播间请求消息来自第一客户端,所述第二直播间请求消息来自第二客户端;所述处理器,用于根据所述第一直播间请求消息确定所述第一客户端的角色,并根据所述第二直播间请求消息确定所述第二客户端的角色;所述收发器,还用于在确定所述第一客户端的角色为主用户、所述第二客户端的角色为仆用户的情况下,仅将所述第一直播媒体流发送给所述代理客户端,以使所述代理客户端将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。
可选的,在本方面的另一种可能实现方式中,当所述网络设备作为代理客户端时,所述收发器,用于分别接收第一客户端发送的用于请求进入直播间的第一直播间请求消息,和,第二客户端发送的用于请求进入所述直播间的第二直播间请求消息;以及,通过代理服务器向媒体服务器发送所述第一直播间请求消息和所述第二直播间请求消息;所述收发器,还用于接收所述代理服务器发送的第一直播媒体流,并且将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。其中,所述第一直播媒体流是所述媒体服务器通过所述代理服务器向所述第一客户端发送的媒体流,所述第一客户端的角色为主用户,所述第二客户端的角色为仆用户。
第六方面,本申请实施例还提供了一种计算机可读存储介质,所述存储介质中存储有指令,当所述指令在计算机或处理器上运行时,用于执行前述第一方面以及第一方面各种实现方式中的方法,或,执行前述第二方面以及第二方面各种实现方式中的方法。
第七方面,本申请实施例还提供了一种计算机程序产品,所述计算机程序产品包括计算机指令,当所述指令被计算机或处理器执行时,可实现前述第一方面和第一方面各种实现方式中的方法,或,实现前述第二方面以及第二方面各种实现方式中的方法。
第八方面,本申请实施例还提供了一种媒体流发送系统,所述系统包括至少一个客户端、代理客户端、代理服务器和媒体服务器,其中每个所述客户端通过所述代理客户端接入直播间,所述系统通过所述代理客户端和所述代理服务器实现前述第一方面、第二方面以及第一方面或第二方面中的各种实现方式所述的媒体流发送方法。其中,所述代理客户端用于执行 第二方面或第二方面的任一实现方式所述的媒体流发送方法,所述代理服务器用于执行第一方面或第一方面的任一实现方式所述的媒体流发送方法。
其中,可选的,所述代理服务器为上述第三方面或第三方面的任一实现方式所述的媒体发送装置,所述代理客户端为上述第四方面或第四方面的任一实现方式所述的媒体发送装置。
结合第八方面,在第八方面的一种可能的实现中,所述代理服务器和所述媒体服务器位于区域数据中心RDC中,所述RDC中还包括Web服务器,所述Web服务器用于为通过代理客户端进入直播间的客户端分配媒体服务器。
结合第八方面,在第八方面的另一种可能的实现中,所述系统还包括企业数据中心EDC和内容源。
可选的,所述媒体流发送系统为内容分发网络CDN系统。
另外,本申请实施例还提供了一种芯片系统,所述芯片系统包括处理器和接口电路,所述接口电路与所述处理器耦合,所述处理器用于执行计算机程序或指令,以实现前述第一方面以及第一方面各种实现方式中的方法,或,实现前述第二方面以及第二方面各种实现方式中的方法;其中所述接口电路用于与所述芯片系统之外的其它模块进行通信。
本申请提供的方法,利用代理客户端和代理服务器在获取主用户的客户端请求的直播媒体流时,缓存部分媒体流片段在代理客户端本地,当由其他客户端进入直播间并请求直播媒体流时,代理客户端将缓存在本地的媒体流直接发送给这些客户端,从而避免了代理服务器再向代理客户端发送直播媒体流。本方法中代理服务器与代理客户端之间也只发送主用户客户端请求的一份直播媒体流,即只需耗费一份广域带宽来传输该直播媒体流,相比于媒体服务器通过代理服务器将直播媒体流发送给各个客户端所占用的传输资源而言减少了发送媒体流的流量,降低了WAN网链路的负载,节约了资源开销。
另外,代理客户端在将一份直播媒体流发送给直播间的所有客户端时还调整该直播媒体流的时间戳,比如当主用户角色的第一客户端退出直播间时,代理客户端将原来发送给第二客户端的第一直播媒体流切换为第二直播媒体流时,调整所述第二直播媒体流的时间戳,从而使得代理客户端在向第二客户端发送第二直播媒体流时无缝对接原来正在播放的第一直播媒体流的媒体内容,避免由于第一客户端的退出导致第二客户端观看的媒体内容出现视频卡顿或其他影响,所以本方法通过代理客户端调整时间戳还保证了用户观看体验。
附图说明
图1为本申请提供的一种直播系统架构的示意图;
图2为本申请实施例提供的一种视频直播双边代理系统架构的示意图;
图3为本申请实施例提供的一种媒体流发送方法的流程图;
图4为本申请实施例提供的另一种媒体流发送方法的流程图;
图5为本申请实施例提供的一种媒体流发送方法的信令流程图;
图6为本申请实施例提供的另一种媒体流发送方法的信令流程图;
图7为本申请实施例提供的又一种媒体流发送方法的信令流程图;
图8为本申请实施例提供的又一种媒体流发送方法的信令流程图;
图9为本申请实施例提供一种媒体流发送装置的结构示意图;
图10为本申请实施例提供一种网络设备的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本申请实施例中的技术方案,并使本申请实施例的上述目的、特征和优点能够更加明显易懂,下面结合附图对本申请实施例中的技术方案作进一步详细的说明。
在对本申请实施例的技术方案说明之前,首先结合附图对本申请实施例的应用场景进行说明。
本申请的技术方案可应用于内容分发网络(content delivery network,CDN)系统中,该系统中新增的设备包括代理服务器(proxy server)和代理客户端(proxy client)。
其中,所述代理服务器用于代理用户的视频承载协议,标识通过代理服务器进入直播间的所有客户端的角色,从媒体服务器中获取至少一个直播媒体流,并将角色是主用户身份的直播媒体流发送给代理客户端。另外,代理服务器还用于在主用户角色的客户端退出直播间时,更新直播间中其他用户的角色,并切换新的直播媒体流。所述代理客户端用于代理用户的视频承载协议,接收代理服务器发送的角色是主用户的客户端的直播媒体流,并将该直播媒体流复制和分发给通过该代理客户端接入的直播间中的所有客户端。
可选的,所述代理服务器可以位于区域数据中心(Region Data Center,RDC)。所述代理服务器具体可以部署在服务器上,或者还可以以网络功能虚拟化(Network Functions Virtualization,NFV)的形式部署在通用客户端设备(Universal Customer Premise Equipment,uCPE)上。
可选的,所述代理客户端可以为位于局域网边缘的设备,该局域网中的客户端通过该代理客户端进入直播间并通过该代理客户端获取直播媒体流。其中,所述代理客户端可以部署在服务器上,或者以NFV的形式部署在uCPE上。
进一步地,如图2所示,本实施例提供了一种视频CDN系统,该系统包括:内容源(content source)101、企业数据中心(enterprise data center,EDC)102、RDC 103、代理客户端104、至少一个客户端(client,C),比如第一客户端C1 105、第二客户端C2 106和第三客户端C3 107。其中,EDC 102中包括多个媒体服务器(media server)和Web服务器(Web server),RDC 103中包括:代理服务器、多个媒体服务器和Web服务器等。其中,代理服务器与代理客户端之间通过WAN网络连接,代理客户端与其关联的至少一个客户端通过局域网(local area network,LAN)连接。
另外,所述CDN直播是一个分布式的内容分发平台,支持多级架构,通过将多个媒体服务器进行分层分级部署,从而为不同地域的用户提供就近服务。其中,所述EDC中的用户在直播间观看直播时,分配的媒体服务器部署可以在RDC中,传输的直播媒体流通过多协议标签交换技术(Multi-Protocol Label Switching,MPLS)专线达到RDC和代理客户端。
进一步地,上述各个设备或网元的功能概况如下表1所示。
Figure PCTCN2020086335-appb-000001
Figure PCTCN2020086335-appb-000002
表1
另外,需要说明的是,在本申请实施例所述的系统中,代理服务器可以对应一个或多个代理客户端。如,该代理服务器对应代理客户端1和代理客户端2,局域网1的客户端通过代理客户端1和该代理服务器进入直播间;局域网2的客户端通过代理客户端2和该代理服务器进入该直播间。并且,该代理服务器可以通过如下实施方式A或实施方式B来确定通过该代理服务器进入该直播间的每个客户端的角色。
实施方式A:对通过同一个代理客户端进入直播间的所有客户端统一确定客户端的角色。如,该代理服务器对应代理客户端1和代理客户端2,在通过代理客户端1进入直播间的客户端中确定至少一个主用户,并将其他的客户端确定为仆用户,并且,在通过代理客户端2进入直播间的客户端中确定至少一个主用户,并将其他的客户端确定为仆用户。在采用实施方式A确定各个客户端的角色时,相应地,代理服务器将角色为主用户的客户端的直播媒体流发送给该代理客户端,进而由该代理客户端将该直播媒体流发送给通过该代理客户端进入直播间的所有客户端。可以理解的是,在采用实施方式A确定客户端的角色时,通过每个代理客户端进入直播间的客户端中均包括角色为主用户的客户端,代理服务器向任一代理客户端发送的媒体流均为通过该代理客户端进入直播间的角色为主用户的客户端的媒体流。
实施方式B:对通过代理服务器进入直播间中的所有客户端统一确定客户端的角色。如,该代理服务器对应代理客户端1和代理客户端2,在通过代理客户端1和代理客户端2进入直播间的所有客户端中确定至少一个主用户,并将其他的客户端确定为仆用户。在采用实施方式B确定客户端的角色时,相应地,将角色为主用户的客户端的直播媒体流发送给所述系统中该代理服务器对应的每个代理客户端,进而再由每个代理客户端将该直播媒体流发送给通过各自代理客户端进入到该直播间的所有客户端。
为了简化表述,本实施例中,所述的角色是主用户的客户端,可简称为:主用户的客户端。同理地,所述角色是仆用户的客户端,可简称为:仆用户的客户端。
具体地,如图3所示,为本实施例提供的一种媒体流发送方法,所述方法为通过同一代理客户端进入直播间的所有客户端提供直播媒体流,具体地,方法包括:
步骤101:代理服务器分别接收同一代理客户端发送的用于请求进入直播间的第一直播间请求消息和第二直播间请求消息,其中第一直播间请求消息来自第一客户端,第二直播间请求消息来自第二客户端。
其中,所述第一直播间请求消息中包括代理客户端的标识,和,所述第二直播间请求消息中包括所述代理客户端的标识,所述标识可以是代理客户端的IP地址或端口号等。所述代理服务器可以根据所述第一直播间请求消息包括的所述代理客户端的标识确定转发所述第一 直播间请求消息的代理客户端,并根据所述第二直播间请求消息包括的所述代理客户端的标识确定转发所述第二直播间请求消息的代理客户端,进而可以确定所述第一直播间请求消息和所述第二直播间请求消息是来自同一代理客户端。
步骤102:代理服务器分别接收媒体服务器通过所述代理服务器向所述第一客户端发送的第一直播媒体流,和,向所述第二客户端发送的第二直播媒体流。
具体的,代理服务器在接收到所述第一客户端发送的第一媒体请求消息后,将该第一媒体请求消息转发给该媒体服务器,并接收该媒体服务器根据该第一媒体请求消息发送的第一直播媒体流,并且,在接收到所述第二客户端发送的第二媒体请求消息后,将该第二媒体请求消息转发给该媒体服务器,并接收该媒体服务器根据该第二媒体请求消息发送的第二直播媒体流。
步骤103:代理服务器根据所述第一直播间请求消息确定所述第一客户端的角色,并且根据所述第二直播间请求消息确定所述第二客户端的角色。
具体可以采用上述“实施方式A”来实现步骤103。
进一步地,一种可能的实现是,对于单一主用户的技术场景,代理服务器每接收到一个直播间请求消息(如所述第二直播间请求消息),判断所述直播间中是否存在通过所述代理客户端进入所述直播间的角色为主用户的客户端;如果存在,则确定发送所述直播间请求消息的客户端(如所述第二客户端)的角色是仆用户(slave user)。如果不存在,则确定所述客户端的角色是主用户(master user)。
另一种可能的实现是,对于多个主用户的技术场景,比如包括一个主要主用户和至少一个备份主用户,步骤103具体包括:代理服务器每接收到一个直播间请求消息(如所述第二直播间请求消息),判断当前直播间中通过所述代理客户端进入所述直播间的角色为主用户的客户端的数量是否达到预设上限,所述预设上限大于等于2,如果达到所述预设上限,则确定发送所述直播间请求消息的客户端(如所述第二客户端)的角色是仆用户。如果未达到所述预设上限且所述数量不为0,则确定所述客户端的角色是备份主用户(secondary-master user)。如果数量为0,则确定所述客户端的角色是主要主用户(main-master user)。
具体也可以采用“实施方式B”来实现所述步骤103,具体的实现方式类似于“实施方式A”的上述具体实现方式。对于单一主用户的技术场景,相对于“实施方式A”的具体实现方式不同点仅在于,判断的是所述直播间中是否存在通过所述代理服务器进入所述直播间的角色为主用户的客户端。对于多个主用户的技术场景,相对于“实施方式A”的具体实现方式不同点仅在于,判断的是当前直播间中通过所述代理服务器进入所述直播间的角色为主用户的客户端的数量是否达到所述预设上限。
此外,还包括:代理服务器以图像组(group of picture,GOP)为单位缓存所述第一直播媒体流。GOP可以指两个I帧之间的图像序列,所述I帧(frame)又称为内部画面(intra picture),一般指利用动态图像专家组(moving picture experts group,MPEG)技术处理后的每个GOP的第一个帧,进一步地,所述MPEG技术处理包括对视频图像进行适度地压缩,使得第I帧可以作为随机访问的参考点,并且无需参考其他画面。
可选的,在代理服务器本地缓存3个GOP,每个GOP的时长为5s。
步骤104:代理服务器在确定所述第一客户端的角色为主用户、所述第二客户端的角色为仆用户的情况下,仅将所述第一直播媒体流发送给所述代理客户端,以使所述代理客户端将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。
具体地,首先,代理服务器在步骤101中接收到所述第一直播间请求消息,在步骤102 中接收所述第一直播媒体流,在步骤103中将所述第一客户端的角色确定为主用户,由于所述第一客户端的角色为主用户,在步骤104中将所述第一客户端的直播媒体流(即所述第一直播媒体流)发送给所述代理客户端,相应地,所述代理客户端将所述第一直播媒体流发送给所述第一客户端。然后,代理服务器在步骤101中接收到所述第二直播间请求消息,在步骤102中接收所述第二直播媒体流,在步骤103中将所述第二客户端的角色确定为仆用户,由于所述第二客户端的角色为仆用户,且与所述第一客户端对应同一代理客户端,所述代理服务器并不向所述代理客户端发送所述第二客户端的媒体流(即所述第二直播媒体流),相应地,所述代理客户端在接收到代理服务器发送的第一直播媒体流后,不仅将该第一直播媒体流发送给该第一客户端,还复制该第一直播媒体流,并将该复制的第一直播媒体流发送给第二客户端。可以理解地,如果直播间中还包括其他更多的客户端,则代理客户端复制多份第一直播媒体流,并将复制的第一直播媒体流发送给通过所述代理客户端进入所述直播间中的每个客户端。
需要说明的是,对于多个主用户的技术场景,第一客户端的角色具体可以为主要主用户,第二客户端可能为仆用户,也可能为备份主用户。在确定该第一客户端为主要主用户的情况下,无论第二客户端的角色为仆用户还是备份主用户,所述代理服务器均是仅将第一客户端请求获取的所述第一直播媒体流发送给代理客户端。
另外,如果所述代理服务器对应多个客户端,且采用上述“实施方式B”确定客户端的角色,则代理服务器还会对应的向其他代理客户端发送该第一直播媒体流,并由其他代理客户端将接收的第一直播媒体流复制分发给对应的客户端。
本实施例中,后续均以采用“实施方式A”确定客户端的角色为例进行描述。
本实施例提供的方法,对于仆用户角色的第二客户端,在请求获取直播媒体流时,代理客户端只需将缓存在本地的主用户角色的第一客户端请求的第一媒体流发送给该第二客户端,从而避免了代理服务器再向代理客户端发送直播媒体流,无需代理服务器为每个通过该代理客户端进入直播间的客户端发送直播媒体流,本方法减少了代理服务器与代理客户端之间发送媒体流的流量,有效地降低出口带宽,节约了资源开销。
此外,本实施例中还包括变更客户端角色的过程,具体地,对于单一主用户的技术场景,所述第一客户端是主用户,第二客户端是仆用户的情况下,方法还包括:代理服务器接收代理客户端发送的退出直播间请求消息,所述退出直播间请求消息用于请求所述第一客户端退出所述直播间;所述代理服务器在确定将所述第二客户端作为新的主用户时,将所述第二客户端的角色从所述仆用户变更为主用户(slave-to-master),并且所述代理服务器将向所述代理客户端发送的第一直播媒体流切换为所述第二直播媒体流,以使得所述代理客户端将所述第二直播媒体流发送给通过所述代理客户端进入所述直播间中的客户端(包括所述第二客户端)。
进一步地,所述代理服务器向代理客户端发送的第一直播媒体流的最后一帧与向第二客户端发送的所述第二直播媒体流的第一帧为相邻帧。
为了保证所述最后一帧与所述第一帧为相邻帧,在代理服务器将向第二客户端发送的第一直播媒体流切换为所述第二直播媒体流之前,还包括媒体流对齐的步骤。所述媒体流对齐步骤具体包括:代理服务器根据第一直播媒体流和第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧;所述代理服务器根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧,并将所述第一切换帧和所 述第二切换帧分别作为向所述第二客户端发送的所述第一直播媒体流的最后一帧与向所述第一客户端发送的所述第二直播媒体流的第一帧。
进一步地,代理服务器在确定第一切换帧和第二切换帧之后将来自所述第一客户端的退出直播间请求消息转发给所述媒体服务器。
同理地,对于多个主用户的技术场景,对应的客户端退出直播间的过程包括:在所述第一客户端是主要主用户,第二客户端是仆用户的情况下,第一客户端请求退出直播间,代理服务器接收来自所述第一客户端的退出直播间请求消息,所述代理服务器在确定将所述第二客户端作为新的备份主用户时,将所述第二客户端的角色从所述仆用户变更为备份主用户;所述代理服务器实时地接收所述媒体服务器发送的第二直播媒体流,并以GOP为单位缓存所述第二直播媒体流。本实施例对于备份主用户的客户端,代理服务器在获取该备份主用户的第二直播媒体流后,将其缓存在本地,以便当该备份主用户的角色变更为主要主用户时,能够直接使用该第二直播媒体流,提高媒体流的传输效率。
另外,可选的,在第一客户端是主要主用户,所述第二客户端是备份主用户的情况下,所述第一客户端退出直播间的流程包括:代理服务器接收来自第一客户端的退出直播间请求消息,所述代理服务器在确定将第二客户端作为新的主要主用户时,将所述第二客户端的角色从所述备份主用户变更为主要主用户(secondary-master to main-master),并将向代理客户端发送的第一直播媒体流切换为第二直播媒体流。
为了提升切换媒体流的效率,代理服务器在每次确认出新的角色为备份主用户的客户端后,缓存接收的该客户端的媒体流,并根据缓存的该客户端的媒体流和当前角色为主要主用户的客户端的媒体流进行对齐,即根据该角色为主要主用户的客户端的媒体流和缓存的该角色为备份主用户的客户端的媒体流识别分别属于这两路媒体流的相同的视频帧。如,接收来自第一客户端的退出直播间请求消息之前,以GOP为单位缓存接收的第二直播媒体流,并根据第一直播媒体流和第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧。进而,在接收来自第一客户端的退出直播间请求消息后,代理服务器根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧;所述代理服务器根据所述第一切换帧和第二切换帧,将向所述第二客户端发送的第一直播媒体流切换为第二直播媒体流,其中,向第二客户端发送的所述第一直播媒体流的最后一帧为所述第一切换帧,向第一客户端发送的所述第二直播媒体流的第一帧为所述第二切换帧。
另外,本申请实施例还提供一种媒体流发送方法,该方法可应用于代理客户端。进一步地,如图4所示,方法包括:
步骤201:代理客户端分别接收第一客户端发送的用于请求进入直播间的第一直播间请求消息,和,第二客户端发送的用于请求进入所述直播间的第二直播间请求消息。
步骤202:代理客户端通过代理服务器向媒体服务器发送所述第一直播间请求消息和所述第二直播间请求消息。
其中,所述代理客户端还可以在向所述代理服务器转发该第一直播间请求消息之前,将所述代理客户端的标识添加到第一直播间请求中,并且,在向所述代理服务器转发该第二直播间请求消息之前,将所述代理客户端的标识添加到第二直播间请求中。可选的,所述代理客户端的标识为所述代理客户端的IP地址。
步骤203:代理客户端接收所述代理服务器发送的第一直播媒体流,所述第一直播媒体流是所述媒体服务器通过所述代理服务器向所述第一客户端发送的媒体流,所述第一客户端 的角色为主用户,所述第二客户端的角色为仆用户。
步骤204:代理客户端将所述第一直播媒体流发送给所述第一客户端和第二客户端。
其中,代理客户端在发送所述第一直播媒体流之前还包括:以GOP为单位缓存所述第一直播媒体流、以及调整该第一直播媒体流的时间戳。
具体地,首先,在步骤201中,代理客户端接收该第一客户端的第一直播间请求消息,在步骤202中将该第一直播间请求消息转发给该代理服务器,由于该代理服务器将该第一客户端确定为主用户,代理客户端在步骤203中接收该第一客户端的直播媒体流(即第一直播媒体流),并在步骤204中将该第一直播媒体流发送给该第一客户端。
然后,在步骤201中,代理客户端接收该第二客户端的第二直播间请求消息,在步骤202中将该第二直播间请求消息转发给该代理服务器,由于该代理服务器将该第二客户端确定为仆用户,所以代理客户端并不会接收到该第二客户端的直播媒体流(即第二直播媒体流),而是直接执行步骤204将该第一直播媒体流复制发送给该第二客户端。在将该第一直播媒体流复制发送给该第二客户端时,该代理客户端还调整该第一直播媒体流的时间戳,使得发送给该第二客户端的第一直播媒体流满足:代理客户端向所述第二客户端发送的第一直播媒体流的第一帧的时间戳为0;且向所述第二客户端发送的第一直播媒体流的相邻帧的时间戳是连续的,所述“连续”是指第一直播视频流的相邻帧的时间间隔相同,为第一直播视频流的帧率f的倒数。
此外,所述方法还包括:在第一客户端退出直播间时,代理客户端转发第一客户端的退出直播间请求消息相关流程,具体包括:代理客户端接收来自第一客户端的退出直播间请求消息,将所述退出直播间请求消息发送给所述代理服务器;接收所述代理服务器根据所述退出直播间请求消息发送的退出直播间响应消息,以及,将所述退出直播间响应消息发送给所述第一客户端。
其中,还包括:代理客户端在接收到所述第一直播间请求消息的情况下,将所述第一客户端的角色标记为工作(working);在接收到所述第二直播间请求消息的情况下,将所述第二客户端的角色标记为工作;在接收到第一客户端发送的退出直播间请求消息的情况下,将所述第一客户端的角色标记为退出(exiting)。并且将所述第一客户端的角色标记更新到“直播间用户关系表”中。
此外,在第一客户端请求退出直播间的情况下,方法还包括:代理客户端接收所述代理服务器发送的第二直播媒体流,所述第二直播媒体流是媒体服务器通过所述代理客户端发送给第二客户端的媒体流,所述第二客户端是角色从仆用户变更为主用户的客户端;代理客户端将所述第二直播媒体流发送给所述第二客户端。
具体地,在所述代理客户端将所述第二直播媒体流发送给所述第二客户端之前,还包括:代理客户端调整所述第二直播媒体流的时间戳,使得调整后的时间戳满足:代理客户端向第二客户端发送的所述第二直播媒体流的第一帧的时间戳与向所述第二客户端发送的所述第一直播媒体流的最后一帧的时间戳连续。进一步地,代理客户端向第二客户端发送的所述第一直播媒体流的最后一帧与向所述第二客户端发送的所述第二直播媒体流的第一帧为相邻帧。
进一步地,所述代理客户端调整直播间中的客户端(如第二客户端)的直播媒体流的时间戳的过程包括:根据公式y=x+Δt,调整媒体流的时间戳,其中,y表示调整后的时间戳,x表示调整前的时间戳,Δt表示时间差。
如果该媒体流为该客户端进入直播间后接收的第一路直播媒体流,如在步骤204中,第一直播媒体流为第二客户端进入直播间后接收的第一路直播媒体流,代理服务器根据该公式 调整媒体流的时间戳使得调整后的时间戳满足以下约束条件:
1、代理客户端向第二客户端发送的该直播媒体流的第一帧的时间戳为0;
2、代理客户端向第二客户端发送的该直播媒体流的相邻帧的时间戳是连续的,即发送的该直播媒体流的相邻帧的时间间隔相同,该时间间隔为该直播视频流的帧率为f的倒数。
由于该直播媒体流为第二客户端进入直播间后接收的第一路直播媒体流,因此,Δt为代理客户端向第二客户端发送的该直播媒体流的第一帧的调整前的时间戳的相反数。
例如,以一个主用户和多个仆用户角色的场景为例,假定代理客户端缓存的第一直播媒体流的GOP的时间长度为5秒(s),且本地缓存3个GOP,所述3个GOP的内容是实时更新的。第一客户端(简称客户端C1)是第一个进入直播间的客户端,则在第0秒客户端C1的角色为主用户,并且在直播间中持续观看第一直播媒体流到第60s时长,此时,代理客户端在本地缓存的视频媒体流的3个GOP分别是:第45s-50s、第50s-55s、第55s-60s的媒体内容,这3个GOP为媒体服务器通过代理服务器发送给客户端C1的媒体流片段,对应发送的每一帧的时间戳为客户端C1的相对时间。
第二客户端(简称客户端C2)在第60秒时进入直播间,角色为仆用户,代理客户端需要将发送给客户端C1的且本地缓存的最新的第一直播媒体流发送给客户端C2,此时距离60s最近的直播媒体流是第3个GOP片段,缓存第55s-60s的媒体内容,其中55s为所述媒体服务器发送的帧的时间戳,所以,需要调整的时间差为Δt=y-x=0-55=-55s,即代理客户端在将第一直播媒体流发送给客户端C2时需要将时间戳减少55s,以便满足上述的约束条件,使得每个进入直播间的客户端C2不用等待,即第0s时刻观看直播视频,达到直播间的客户端C1和客户端C2能“同时”观看视频的有益效果。
进一步地,还包括:当客户端C1请求退出直播间时,代理服务器需要将向客户端C2发送的第一直播媒体流切换为第二直播媒体流,此时客户端C2的角色变更为主用户,且所述第二直播媒体流是媒体服务器发送给客户端C2的媒体流。对应的,代理客户端接收媒体服务器发送的第二直播媒体流,并调整所述第二直播媒体流的时间戳。
例如,如果在视频播放的第120s时客户端C1退出直播间,代理服务器确定将客户端C2的角色变更为主用户,然后该代理服务器向代理客户端发送客户端C2的第二直播媒体流。该代理客户端接收并缓存该第二直播媒体流,假设在第120s时,代理客户端本地缓存的3个GOP的媒体内容分别是:第105s-110s、第110s-115s、第115s-120s,经过10s后代理客户端缓存最新的GOP 1为第115s-120s的视频内容,该GOP 1中帧上的时间戳为客户端C1的相对时间,当客户端C1退出直播间后,代理客户端本地缓存了GOP 2和GOP 3分别是第0-5s、第5s-10s的媒体内容,且这两个GOP中帧上的时间戳为客户端C2的相对时间,所以计算调整的时间差为Δt=120-55-0=65s,即代理客户端发送给新的主用户客户端C2的第二直播媒体流在帧的时间戳上需要增加65s。
综合上述,代理客户端调整时间戳时,可分为两种情况来计算时间差,具体地,
情况1:客户端未接收过媒体流,即当前媒体流是该客户端进入该直播间之后接收的第一路媒体流,则时间差为Δt=0-t2=-t2,其中t2表示代理客户端接收代理服务器发送的,且需要转发给客户端的媒体流的第一帧的时间戳。
情况2:客户端已经接收过媒体流,即代理客户端向该客户端发送的媒体流由前一主用户的媒体流切换为当前主用户的媒体流,则时间差为Δt=(t1+m)-t2,其中t2表示代理客户端在媒体流切换后向该客户端发送的媒体流(即当前主用户的媒体流)的第一帧修改前的 时间戳,t1表示代理客户端在媒体流切换前向该客户端发送的媒体流(即前一主用户的媒体流)的最后一帧修改后的时间戳,对应的下一个视频帧的时间戳为t1+m,m=1/f,例如f=20fps,发送所述视频帧的时间间隔为m=1s/20=0.05s即50ms。
本实施例的方法,利用代理客户端和代理服务器在获取主用户的客户端请求的直播媒体流时,缓存部分媒体流片段在代理客户端本地,当由其他客户端进入直播间并请求直播媒体流时,代理客户端将缓存在本地的媒体流直接发送给这些客户端,从而避免了代理服务器再向代理客户端发送直播媒体流。本方法中代理服务器与代理客户端之间也只发送主用户客户端请求的一份直播媒体流,即只需耗费一份广域带宽来传输该直播媒体流,相比于媒体服务器通过代理服务器将直播媒体流发送给各个客户端所占用的传输资源而言减少了发送媒体流的流量,降低了WAN网链路的负载,节约了资源开销。
另外,代理客户端在将一份直播媒体流发送给直播间的所有客户端时还调整该直播媒体流的时间戳,比如当主用户角色的第一客户端退出直播间时,代理客户端将原来发送给第二客户端的第一直播媒体流切换为第二直播媒体流时,调整所述第二直播媒体流的时间戳,从而使得代理客户端在向第二客户端发送第二直播媒体流时无缝对接原来正在播放的第一直播媒体流的媒体内容,避免由于第一客户端的退出导致第二客户端观看的媒体内容出现视频卡顿或其他影响,所以本方法通过代理客户端调整时间戳还保证了用户观看体验。
下面对本申请实施例提供的方法进行详细地说明。
实施例一
本实施例提供了一种视频直播媒体流发送的方法,该方法可应用于图2所示视频直播系统中,该方法包括了代理服务器向通过同一代理客户端进入直播间的第一客户端和第二客户端提供直播媒体流,其中所述直播媒体流来源于内容源,并通过RDC中的媒体服务器转发。进一步地,如图5所示,该方法共包括39个步骤(step,S),从S1至S39。
其中,从S1至S18为第一客户端(以下简称“客户端C1”)进入直播间并获取直播媒体流的过程;从S19至S39为第二客户端(以下简称“客户端C2”)进入直播间并获取直播媒体流的过程。
具体地,对于客户端C1进入直播间并获取直播媒体流的过程包括:
S1:内容源向EDC中的媒体服务器发送第一直播媒体流。
S2:EDC中的媒体服务器接收第一直播媒体流,并将该第一媒体流发送给下一级RDC中的媒体服务器。其中,在发送第一直播媒体流之前还包括:EDC中Web服务器对下一级RDC中的媒体服务器进行鉴权的步骤,当且仅当鉴权结果合格后,RDC中的媒体服务器将第一直播媒体流发送给RDC中的媒体服务器。
可选的,S2还包括:代理服务器(proxy server)根据第一直播媒体流的业务特征识别被代理的客户端对应的传输协议;其中,所述业务特征包括Web服务器的IP地址和端口号,例如对于超文本传输协议(Hyper Text Transfer Protocol,HTTP)协议,可配置的业务特征包括:Web服务器的IP地址和端口号。进一步地,还可以确定HTTP协议所对应的传输协议为传输控制协议(Transmission Control Protocol,TCP),以便利用该TCP协议传输媒体流。
S3:客户端C1向RDC中的Web服务器发送可以访问的媒体服务器的请求消息。进一步地,所述请求消息中包括:客户端C1的用户名、IP地址、直播间名称、客户端C1通过鉴权后得到的密钥Token等信息,其中IP地址用于确定客户端C1的位置。具体地,客户端C1将所述请求消息发送给代理客户端,所述代理客户端接收到该请求消息后转发给代理服务器,然后 代理服务器再将该请求消息转发至RDC中的Web服务器。
S4:RDC中的Web服务器接收所述请求消息,并向客户端C1发送可以访问的媒体服务器的响应消息,所述响应消息用于告知客户端C1其可以访问的媒体服务器。具体地,Web服务器根据所述请求消息确定能够为客户端C1提供媒体流服务的目标媒体服务器,所述目标媒体服务器为RDC中多个媒体服务器中的一个,然后将所述响应消息发送给客户端C1,所述响应消息中包括目标媒体服务器的相关信息,例如目标媒体服务器的统一资源定位符(Uniform Resource Locator,URL)信息、IP地址和端口号等。
具体地,RDC中的Web服务器将所述响应消息发送给代理服务器,所述代理服务器将该响应消息发送给代理客户端,所述代理客户端再转发给响应消息给客户端C1。
其中,Web服务器根据客户端C1发送的访问媒体服务器的请求消息中,携带的IP地址确定客户端C1的位置,并根据该位置信息选择与客户端C1距离较近的媒体服务器作为所述目标媒体服务器。
S5:所述响应消息中携带所述目标媒体服务器的相关信息,例如目标媒体服务器的URL信息、IP地址和端口号等,因此,代理服务器和代理客户端在转发所述响应消息时,得到客户端C1可以访问的媒体服务器的信息,即所述目标媒体服务器的相关信息。
S6:客户端C1向代理客户端发送用于请求进入直播间的第一直播间请求消息,所述第一直播间请求消息表示客户端C1请求进入直播间。其中,第一直播间请求消息中包括客户端C1的用户名、IP地址、端口号、直播间名称、通过鉴权后得到的Token等。
S7:代理客户端接收客户端C1发送的第一直播间请求消息,并设置客户端C1角色为工作(working)状态。同时建立“直播间用户关系表”,所述直播间用户关系表中添加一条关于客户端C1的记录,具体地,记录的内容包括:客户端C1的IP地址、端口号、用户状态、用户名、RDC中选择的目标媒体服务器的IP地址和端口号、直播间名称等信息。其中,客户端C1的用户状态为working。其中所述客户端C1的IP地址可以是数据库中存储的主键(primary key)。
此外,还包括:代理客户端将自己的标识添加在所述第一直播间请求消息中,所述代理客户端的标识为代理客户端的IP地址或端口号等。
S8:代理客户端将添加有所述代理客户端标识的第一直播间请求消息发送给代理服务器,其中,修改后的所述第一直播间请求消息中包括:所述代理客户端的标识、客户端C1的用户名、直播间名称、通过鉴权后得到的Token等信息。
S9:代理服务器接收所述修改后的第一直播间请求消息,根据该第一直播间请求消息确定客户端C1的角色,并刷新所述直播间用户关系表。具体地,确定客户端C1的角色包括:判断在接收到所述第一直播间请求消息时,通过所述代理客户端进入到所述直播间的客户端中是否存在角色为主用户的客户端;如果存在,则确定所述客户端C1为仆用户;如果不存在,则确定客户端C1为主用户。本实施例中,由于客户端C1是第一个通过代理客户端进入直播间的用户,所以不存在主用户,因此代理服务器接收到该第一直播间请求消息时,确定客户端C1的角色为主用户,并标识所述客户端C1的角色为主用户。
另外,还包括:代理服务器在确定客户端C1的角色后,刷新“直播间用户关系表”,标记客户端C1的角色是主用户。可理解地,代理服务器可根据接收的通过同一代理客户端发送的直播间请求消息,随时更新“直播间用户关系表”,以便时刻记录直播间中各个客户端的角色状态。可选的,代理服务器在所述“直播间用户关系表”中还记录有代理客户端的标识(IP地址和端口号)。
本实施例中,设置直播间中主用户角色的客户端数量为1,即直播间中只有一个主用户,其余的客户端都是仆用户,在这种技术场景下可称为单一主用户场景。
S10:代理服务器发送所述第一直播间请求消息给RDC中的媒体服务器。其中,所述第一直播间请求消息中不包括所述代理客户端的标识。
其中,上述步骤S9和S10之间顺序可以互换,本实施例对此不严格限制。
S11:RDC中的媒体服务器接收所述第一直播间请求消息,并向客户端C1发送第一直播间响应消息。所述第一直播间响应消息用于通知客户端C1进入直播间成功。具体地,媒体服务器先将所述第一直播间响应消息通过代理服务器转发给代理客户端,然后代理客户端再将该第一直播间响应消息转发给客户端C1。
S12:客户端C1向代理客户端发送第一媒体请求消息,所述第一媒体请求消息用于向媒体服务器请求获取第一直播媒体流。可选的,所述第一媒体请求消息中携带的客户端C1的第一标识,所述第一标识用于唯一标识所述客户端C1,本实施例中,所述第一标识包括客户端C1的IP地址和用户名等。
具体地,代理客户端接收到该第一媒体请求消息之后,将其转发给代理服务器,代理服务器再将该第一媒体请求消息发送给RDC中的媒体服务器。
S13:媒体服务器接收到所述第一媒体请求消息之后,向客户端C1发送第一媒体响应消息。所述第一媒体响应消息用于通知客户端C1允许获得第一直播媒体流。具体地,媒体服务器将第一媒体响应消息发送给代理服务器,然后代理服务器转发该第一媒体响应消息给代理客户端,最后代理客户端再转发该第一媒体响应消息给客户端C1。
S14:媒体服务器向代理服务器发送第一直播媒体流。
S15:代理服务器实时地获取媒体服务器发送的第一直播媒体流,然后将该第一直播媒体流缓存在本地,具体地,代理服务器在本地以GOP为单位缓存该第一直播媒体流片段,比如缓存最新的3个GOP的媒体流片段,分别是:t1-t2,t2-t3,t3-t4。
S16:代理服务器将缓存的第一直播媒体流片段发送给代理客户端,以便由代理客户端将该第一直播媒体流发送给客户端C1。
S17:代理客户端接收所述代理服务器发送的第一直播媒体流,并以GOP为单位将该第一直播媒体流缓存在本地。其中,代理客户端只缓存若干个最新的第一直播媒体流片段。
S18:代理客户端将缓存的第一直播媒体流发送给客户端C1。
其中,代理客户端在向客户端C1发送第一直播媒体流的过程中,还需要调整所述第一直播媒体流的时间戳,使得调整后的时间戳满足:代理客户端向客户端C1发送的第一直播媒体流的第一帧的时间戳为0,并且,向客户端C1发送的所述第一直播媒体流的相邻帧的时间戳是连续的。所述“连续”是指客户端C1接收的第一直播媒体流的相邻视频帧的时间间隔相同,其中,所述时间间隔为帧率f的倒数。
下面介绍客户端C2进入直播间,并获取直播媒体流的方法。具体包括以下步骤:
S19:客户端C2向RDC中的Web服务器发送可以访问的媒体服务器请求消息,所述请求消息中包括客户端C2的用户名、IP地址、直播间名称、客户端C2通过鉴权后得到的密钥Token等信息。具体地,客户端C2通过代理客户端和代理服务器转发该请求消息给RDC中的Web服务器,且在转发的过程中,代理客户端和代理服务器均获取所述请求消息中携带的信息。
S20:RDC中的Web服务器接收所述请求消息,并向客户端C2发送响应消息,所述响应消息用于告知客户端C2其可以访问的媒体服务器。与前述步骤S4相同,Web服务器在多个媒体服务器中选择一个,用于为客户端C2提供媒体流服务,并将该选择的媒体服务器的相关 信息,例如媒体服务器的URL信息、IP地址和端口号等通过所述响应消息发送给代理服务器和代理客户端。
S21:代理客户端和代理服务器在转发所述响应消息的过程中,获得所述请求消息中携带的信息,包括客户端C2可以访问的媒体服务器的信息。例如媒体服务器的IP地址、端口号等。
S22:客户端C2向代理客户端发送用于请求进入直播间的第二直播间请求消息,所述第二直播间请求消息表示客户端C2请求进入直播间。其中,第二直播间请求消息中包括客户端C2的用户名、IP地址、端口号、直播间名称、通过鉴权后得到的Token等。
S23:代理客户端接收客户端C2发送的第二直播间请求消息,并设置客户端C2角色为工作(working)状态。同时在“直播间用户关系表”中添加一条关于客户端C2的记录,具体地,记录的内容包括:客户端C2的IP地址、端口号、用户状态、用户名、RDC中选择的目标媒体服务器的IP地址和端口号、直播间名称等信息。其中,客户端C2的用户状态为working。其中所述客户端C2的IP地址可以是数据库中存储的主键。
此外,还包括:代理客户端将自己的标识添加在所述第二直播间请求消息中,所述代理客户端的标识为代理客户端的IP地址或端口号等。
S24:代理客户端将添加有所述代理客户端标识的第二直播间请求消息发送给代理服务器。其中,修改后的所述第二直播间请求消息中包括:所述代理客户端的标识、客户端C2的用户名、直播间名称、通过鉴权后得到的Token等信息。
S25:代理服务器接收代理客户端发送的所述修改的第二直播间请求消息,根据该第二直播间请求消息确定客户端C2的角色,并刷新所述直播间用户关系表。具体地,一种可能的实现方式是,代理服务器接收到该第二直播间请求消息后,判断当前所述直播间中是否存在通过所述代理客户端进入所述直播间的角色为主用户的客户端,如果存在,则确定所述客户端C2的角色为仆用户。本实施例中,当前直播间中已经存在客户端C1的角色为主用户的客户端,所以确定客户端C2的角色为仆用户。
另外,S25中还包括,代理服务器刷新“直播间用户关系表”,将客户端C2的角色标识为仆用户(slave)。另外,还包括:代理服务器将代理客户端的标识,比如代理客户端的IP地址和端口号添加在由于客户端C2的记录中。
S26:代理服务器发送所述第二直播间请求消息给RDC中的媒体服务器。其中,所述第二直播间请求消息中不包括所述代理客户端的标识。
S27:媒体服务器接收所述第二直播间请求消息,并向客户端C2发送第二直播间响应消息,所述第二直播间响应消息用于通知客户端C2进入直播间成功。具体地,媒体服务器将所述第二直播间响应消息通过代理服务器和代理客户端,然后代理客户端再将该第二直播间响应消息转发给客户端C2。
S28:客户端C2向代理客户端发送第二媒体请求消息,所述第二媒体请求消息用于向媒体服务器请求获取直播媒体流。可选的,所述第二媒体请求消息中携带的客户端C2的第二标识,所述第二标识用于唯一标识所述客户端C2,本实施例中,所述第二标识包括客户端C2的IP地址和用户名等。
具体地,代理客户端接收到该第二媒体请求消息之后,将其转发给代理服务器,代理服务器再将该第二媒体请求消息发送给RDC中的媒体服务器。
S29:媒体服务器接收到所述第二媒体请求消息之后,向客户端C2发送第二媒体响应消息,所述第二媒体响应消息用于通知客户端C2允许获得第一直播媒体流。具体地,媒体服务 器将该第二媒体响应消息发送给代理服务器,然后代理服务器转发该第二媒体响应消息给代理客户端,最后代理客户端再转发该第二媒体响应消息给客户端C2。
S30:代理客户端将本地缓存的第一直播媒体流发送给客户端C2,进一步地,在发送所述第一直播媒体流时还调整第一直播媒体流的时间戳,使得调整后的时间戳满足:代理客户端向客户端C2发送的第一直播媒体流的第一帧的时间戳为0,并且,向客户端C2发送的所述第一直播媒体流的相邻帧的时间戳连续。
S31:所述媒体服务器向代理服务器发送第二直播媒体流,所述第二直播媒体流是发送给客户端C2的媒体流,所述客户端C2的角色是仆用户。
S32:代理服务器接收该第二直播媒体流后,不缓存且也不转发向客户端C2转发该第二直播媒体流,因为第二直播媒体流是发送给仆用户的客户端C2的媒体流。
S33:媒体服务器实时地向所述代理服务器发送第一直播媒体流。
S34:代理服务器接收到所述媒体服务器发送的第一直播媒体流,并以GOP为单位将所述第一直播媒体流的片段缓存在本地。本实施例中代理服务器在本地缓存3个GOP,还可以缓存更多或更少个数的GOP,本实施例对此不进行限制。
S35:代理服务器将所述第一直播媒体流发送给代理客户端。
S36:代理客户端接收所述第一直播媒体流,并以GOP为单位将该第一直播媒体流片段缓存在本地。
S37:代理客户端根据“直播间用户关系表”中记录的内容,确定直播间中主用户和仆用户的客户端数量,将缓存的第一直播媒体流片段进行复制,以便准备发送给直播间中的客户端。本实施例中当前直播间中只有两个客户端,客户端C1和客户端C2,其中客户端C1是主用户,客户端C2是仆用户,所以代理客户端将第一直播媒体流复制一份,以准备发送给客户端C2。
S38:代理客户端将本地缓存的第一直播媒体流发送给客户端C1。另外,还包括:代理客户端根据客户端C1接收到媒体流的视频帧的时间来调整第一直播媒体流中的时间戳。
S39:代理客户端将本地缓存的第一直播媒体流发送给客户端C2。另外,还包括:代理客户端根据客户端C2接收到媒体流的视频帧的时间来调整第一直播媒体流中的时间戳。
并且,代理客户端通过调整进入直播间用户观看视频帧的时间戳,使得直播间中的客户端C1和客户端C2能够“同步”地观看第一直播的媒体内容,提高用户体验。
本实施例的方法,利用代理客户端和代理服务器在获取主用户的第一客户端请求的直播媒体流时,缓存部分该直播媒体流片段在代理客户端本地,当第二客户端进入直播间并请求直播媒体流时,代理客户端将缓存在本地的直播媒体流直接发送给该第二客户端,从而避免了代理服务器再向代理客户端发送直播媒体流,本方法代理服务器只需要发送一份直播媒体流给代理客户端,即只需耗费一份广域带宽来传输直播媒体流,能够有效地减少了发送媒体流的流量,降低了WAN网链路的负载,节约了资源开销。
另外,本实施例的方法还可以将客户端C1的第一直播间请求消息与第一媒体请求消息合并成一个消息,且该合并后的消息具有所述第一直播间请求消息和第一媒体请求消息两部分功能,则代理服务器在确定客户端C1角色时,可以根据所述第一媒体请求消息的数量来统计当前进入直播间的主用户角色的客户端总数。同理地,客户端C2的第二直播间请求消息与第二媒体请求消息也可合并成一个消息,对应的确定客户端C2的角色的方法也相同,本实施例对此不再赘述。
此外,本实施例提供的方法还包括:当客户端C2的角色发生变化时,比如将仆用户角色 变更为主用户,媒体服务器向客户端C2继续发送直播媒体流的过程。进一步地,如图6所示,包括S40至S53,具体的方法流程如下:
S40:客户端C1向代理客户端发送退出直播间请求消息,所述退出直播间请求消息用于请求客户端C1退出直播间。所述退出直播间请求消息中包括客户端C1的用户名、IP地址、端口号、用户角色、直播间名称等信息。
S41:代理客户端接收所述退出直播间请求消息后,标记客户端C1的角色为退出(Exiting)用户,并记录在“直播间用户关系表”中。
S42:代理客户端将所述退出直播间请求消息发送给代理服务器。
S43:代理服务器接收所述退出直播间请求消息,暂不转发该退出直播间请求消息给媒体服务器,因为,此时以客户端C1为主用户请求的第一直播媒体流正在被客户端C2观看。另外,标记客户端C1的角色为退出(Exiting)用户,并记录在“直播间用户关系表”中。
S44:代理服务器从直播间的客户端中选择一个作为新的主用户,本实施例中,通过所述代理客户端进入所述直播间的客户端只有客户端C1和C2,且当客户端C1请求退出直播间时,选择客户端C2作为新的主用户,并且将客户端C2的角色从仆用户变更为主用户,同时标记为slave-to-master用户。
S45:媒体服务器实时地向代理服务器发送第二直播媒体流。其中,所述第二直播媒体流与所述第一直播媒体流的内容相同,都是来自于内容源。
S46:代理服务器接收所述第二直播媒体流,并将该第二直播媒体流以GOP为单位缓存在本地。
另外,还包括:代理服务器利用对齐算法对齐所述第一直播媒体流和所述第二直播媒体流。具体地,过程包括:代理服务器每接收到第一直播媒体流的一个I帧,将该I帧与本地缓存的第二直播媒体流的I帧进行比较,并且,每接收到第二直播媒体流的一个I帧,将该I帧与本地缓存的第一直播媒体流的I帧进行比较,如果通过上述比较过程找到分别属于第一直播媒体流和第二直播媒体流且媒体内容相同的I帧(后续分别称为I帧a和I帧b),则确定这两个直播媒体流对齐。可以理解的是,I帧a和I帧b为相同视频帧。进而根据I帧a和I帧b确定切换点,即确定向代理客户端发送的第一直播媒体流的最后一帧(后续称为切换帧x)和向所述代理客户端发送的第二直播媒体流的第一帧(后续称为切换帧y),切换帧x与切换帧y为相邻帧。具体可以将第一直播媒体流中I帧a后的第n帧确定为切换帧x,并且将第二直播媒体流中I帧b后的第n+1帧确定为切换帧y,其中n为大于或等于0的整数。由于I帧a和I帧b为相同视频帧,I帧a后的第n帧和I帧b后的第n+1帧自然为相邻帧。
本实施例中,当主用户角色的客户端C1退出直播间时,利用新的主用户的客户端C2请求并获取第二直播媒体流,并对齐所述第一直播媒体流和第二直播媒体流的第I帧,使得代理服务器在向代理客户端发送第二直播媒体流时无缝对接原来正在播放的第一直播媒体流的媒体内容,避免了由于代理服务器切换直播媒体流时,对直播间的用户产生的视频内容出现重复播放或少播放的影响。
S47:代理服务器发送所述退出直播间请求消息给媒体服务器。
S48:媒体服务器接收到所述退出直播间请求消息后,向代理服务器发送退出直播间响应消息,所述退出直播间响应消息用于通知客户端C1退出成功。
S49:代理服务器从“直播间用户关系表”中删除客户端C1对应的记录。
其中,上述S48和S49之间无严格时序关系,可以互换。
S50:代理服务器接收所述媒体服务器发送的退出直播间响应消息,并转发该退出直播间 响应消息给代理客户端。
S51:代理客户端接收所述代理服务器发送的所述退出直播间响应消息,并从“直播间用户关系表”中删除客户端C1对应的记录。
S52:代理客户端将所述退出直播间响应消息发送给客户端C1。
另外,还包括:代理服务器缓存的第二直播媒体流发送给代理客户端,代理客户端接所述第二直播媒体流后以GOP为单位缓存在本地,然后将缓存的第二直播媒体流片段发送给客户端C2,从而保证直播间中客户端C2正常观看直播媒体内容。并且,所述代理客户端在向客户端C2发送第二直播媒体流时,调整所述第二直播媒体流的时间戳,使得客户端C2接收的第二直播媒体流的第一帧的时间戳和第一直播媒体流的最后一帧的时间戳连续,对应的时间间隔为帧率参数f的倒数。具体的调整过程,可参见上述实施例的描述,此处不再赘述。
本实施例提供的方法,当主用户的客户端退出直播间时,代理服务器从直播间中选择新的客户端作为新的主用户,并将该新的主用户的直播媒体流对齐后发送给代理客户端。代理客户端接收代理服务器发送的新的主用户的直播媒体流后,调整该直播媒体流的时间戳,从而使得直播间中其他正在观看媒体内容的用户对媒体流的切换无感知,本方法保证了直播间中用户的观看体验。
实施例二
本实施例提供了另一种直播媒体流发送方法,该方法应用于多个主用户角色的技术场景,其中所述多个主用户是指直播间中设置的主用户角色的客户端的数量大于等于2,进一步地,包括一个主要主用户,可标识为main master用户,以及多个备份主用户,可标识为secondary master用户,另外还包括至少一个角色是仆(slave)用户。进一步地,本方法中通过同一代理客户端进入直播间的客户端在请求和获取直播媒体流的过程与前述实施例一近似,但不同之处包括:对于客户端角色的标识,以及当有主用户角色的客户端退出直播间时,对仍在直播间中的客户端的角色的标识和直播媒体流的复制分发。
具体地,本实施例中还包括第三客户端(以下简称“客户端C3”),且设置直播间中主用户角色的数量的预设上限为2,在这种情况下,每个客户端进入直播间并请求获取直播媒体流的过程:如图7所示,包括如下:
S1至S18,为客户端C1进入直播间并请求获取直播媒体流的过程。该过程与实施例一中的S1至S18相同,区别仅在于S9中刷新“直播间用户关系表”时,将客户端C1的角色标记设置为主要主用户(main-master)。其余的步骤可参见上述实施例一的描述,此处不再赘述。
其中,在代理服务器获取媒体服务器发送的第一直播媒体流时,以GOP为单位缓存3个第一直播媒体流片段在本地,并实时地将第一直播媒体流片段通过代理客户端发送给客户端C1。
S19至S39,为客户端C2进入直播间并请求获取直播媒体流的过程。具体地,包括:S19至S24,为客户端C2通过代理客户端进入直播间并向该代理客户端发送第二直播间请求消息的过程,该过程与实施例一的S19至S24相同,所以可参见上述实施例一的具体描述,此处不再赘述。
S25:代理服务器接收代理客户端发送的第二直播间请求消息后,根据该第二直播间请求消息确定客户端C2的角色。具体地,判断获取第二直播间请求消息时,通过代理客户端进入直播间的角色为主用户的客户端的数量是否达到预设上限,如果达到所述预设上限,则确定客户端C2为仆用户;如果未达到所述预设上限且主用户的客户端的数量不为0,则确定客户端C2为备份主用户。本实施例中,所述预设上限为2,代理服务器判断当前共获取两个直播 间请求消息,分别是来自客户端C1的第一直播间请求消息和客户端C2的第二直播间请求消息,且客户端C1的角色是主要主用户,此时直播间中主用户的数量为1,未达到所述预设上限,所以代理服务器确定客户端C2的角色是备份主用户。
另外,还包括在所述“直播间用户关系表”中刷新关于客户端C2的记录,将客户端C2的角色标记为备份主用户。
还包括:S26至S39,为客户端C2获取代理客户端发送的第一直播媒体流的过程,以及代理客户端将所述第一直播媒体流发送给客户端C1的过程,该过程与实施例一中的S26至S39相同,所以本实施例对此不再详细赘述。
但是,在S32中,代理服务器从媒体服务器获取第二直播媒体流后,所述第二直播媒体流是发送给客户端C2的媒体流,所述客户端C2的角色是备份主用户,所述代理服务器将该第二直播媒体流以GOP为单位缓存在本地,并使用对齐算法对齐所述第一直播媒体流和所述第二直播媒体流。
具体地,代理服务器利用对齐算法对齐所述第一直播媒体流和第二直播媒体流的过程,包括:代理服务器每接收到第一直播媒体流的一个I帧,将该I帧与本地缓存的第二直播媒体流的I帧进行比较,并且,每接收到第二直播媒体流的一个I帧,将该I帧与本地缓存的第一直播媒体流的I帧进行比较,如果通过上述比较过程找到分别属于第一直播媒体流和第二直播媒体流且媒体内容相同的I帧(后续分别称为I帧a和I帧b),则确定这两个直播媒体流对齐。可以理解的是,I帧a和I帧b为相同视频帧。进而根据I帧a和I帧b确定切换点,即确定向客户端C2发送的第一直播媒体流的最后一帧(后续称为切换帧x)和向各客户端C2发送的第二直播媒体流的第一帧(后续称为切换帧y),切换帧x与切换帧y为相邻帧。具体可以将第一直播媒体流中I帧a后的第n帧确定为切换帧x,并且将第二直播媒体流中I帧b后的第n+1帧确定为切换帧y,其中n为大于或等于0的整数,由于所述I帧a和I帧b为相同视频帧,所以I帧a后的第n帧和I帧b后的第n+1帧自然为相邻帧。
本实施例中,对于备份主用户角色的第二客户端,代理服务器在获取媒体服务器发送的第二直播媒体流后,在代理服务器本地缓存该第二直播媒体流以备后续使用。
下面从步骤S40至S61为客户端C3进入直播间,请求并获取直播媒体流的过程,具体地包括:
S40:客户端C3向RDC中的Web服务器发送可以访问的媒体服务器的请求消息。进一步地,所述请求消息中包括:客户端C3的用户名、IP地址、直播间名称、客户端C3通过鉴权后得到的密钥Token等信息,其中IP地址用于确定客户端C3的位置。
S41:RDC中的Web服务器接收所述请求消息,并向客户端C3发送可以访问的媒体服务器的响应消息,所述响应消息用于告知客户端C3其可以访问的媒体服务器。具体地,RDC中的Web服务器将所述响应消息发送给代理服务器,所述代理服务器将该响应消息发送给代理客户端,所述代理客户端再转发给响应消息给客户端C3。
其中,Web服务器根据客户端C3发送的访问媒体服务器的请求消息中,携带的IP地址确定客户端C3的位置,并根据该位置信息选择与客户端C3距离较近的媒体服务器作为所述目标媒体服务器。
S42:所述响应消息中携带所述目标媒体服务器的相关信息,例如目标媒体服务器的URL信息、IP地址和端口号等,因此,代理服务器和代理客户端在转发所述响应消息时,得到客户端C3可以访问的媒体服务器的信息,即所述目标媒体服务器的相关信息。
S43:客户端C3向代理客户端发送用于请求进入直播间的第三直播间请求消息,所述第 三直播间请求消息表示客户端C3请求进入直播间。其中,第三直播间请求消息中包括客户端C3的用户名、IP地址、端口号、直播间名称、通过鉴权后得到的Token等。
S44:代理客户端接收所述第三直播间请求消息,并设置客户端C3角色为工作(working)状态。同时更新“直播间用户关系表”,在直播间用户关系表中添加一条关于客户端C3的记录,具体地,记录的内容包括:客户端C3的IP地址、端口号、用户状态、用户名、RDC中选择的目标媒体服务器的IP地址和端口号、直播间名称等信息。其中,客户端C3的用户状态为working。此外,所述记录中还包括:代理客户端的标识,例如代理客户端的IP地址和端口号等。
此外,还包括:代理客户端将自己的标识添加在所述第三直播间请求消息中,所述代理客户端的标识为代理客户端的IP地址或端口号等。
S45:代理客户端将添加有所述代理客户端标识的第三直播间请求消息发送给代理服务器,其中,修改后的所述第三直播间请求消息中包括:所述代理客户端的标识、客户端C3的用户名、直播间名称、通过鉴权后得到的Token等。
S46:代理服务器接收所述修改后的第三直播间请求消息,根据该第三请求消息确定客户端C3的角色,并刷新所述直播间用户关系表。具体地,确定客户端C3的角色包括:判断在接收到所述第三直播间请求消息时,通过所述代理客户端进入到所述直播间的主用户的数量是否达到预设上限,如果达到,则确定客户端C3的角色是仆用户;如果未达到预设上限且所述主用户的数量不为0,则确定客户端C3的角色备份主用户。本实施例中,所述预设上限为2,客户端C3通过代理客户端进入直播间时,当前主用户的客户端数量为2,等于所述预设上限,所以确定客户端C3的角色是仆用户。
另外,还包括:代理服务器在确定客户端C3的角色后,刷新“直播间用户关系表”,标记客户端C3的角色是仆用户。
S47:代理服务器发送所述第三直播间请求消息给RDC中的媒体服务器。其中,所述第三直播间请求消息中不包括所述代理客户端的标识。
S48:RDC中的媒体服务器接收所述第三直播间请求消息,并发送第三直播间响应消息给客户端C3,所述第三直播间响应消息用于通知客户端C3进入直播间成功。具体地,所述媒体服务器先将所述第三直播间响应消息发送给代理服务器,然后代理服务器再将该第三直播间响应消息发送给代理客户端,最后该代理客户端将该第三直播间响应消息转发给客户端C3。
S49:客户端C3发送第三媒体请求消息,所述第三媒体请求消息用于向媒体服务器请求获取直播媒体流。可选的,所述第三媒体请求消息中携带的客户端C3的标识,所述标识用于唯一标识所述客户端C3,本实施例中,所述标识包括客户端C3的IP地址和用户名等。
S50:媒体服务器接收到所述第三媒体请求消息之后,向客户端C3发送第三媒体响应消息,所述第三媒体响应消息用于通知客户端C3允许获得直播媒体流。具体地,媒体服务器将所述第三媒体响应消息通过代理服务器和代理客户端转发给所述客户端C3。
S51:代理客户端将本地缓存的第一直播媒体流发送给客户端C3。其中,代理客户端在发送所述第一直播媒体流之前,还需要调整所述第一直播媒体流的时间戳,使得所述客户端C3接收到所述第一直播媒体流的第一帧的时间戳为0,并且,向客户端C3发送的所述第一直播媒体流的相邻帧的时间戳是连续的。
S52:媒体服务器向代理服务器发送第三直播媒体流,所述第三直播媒体流来源于内容源,且所述第三直播媒体流是发送给所述客户端C3的媒体流。
S53:代理服务器接收所述第三直播媒体流后,不缓存也不转发该第三直播媒体流,因为 客户端C3的角色是仆用户。
S54:代理服务器实时地接收媒体服务器发送的第一直播媒体流。
S55:代理服务器将所述第一直播媒体流以GOP为单位缓存在本地。其中,代理服务器在本地只缓存若干个最新的GOP。
S56:代理服务器将缓存的第一直播媒体流发送给代理客户端。
S57:代理客户端将所述第一直播媒体流以GOP为单位缓存在本地。
S58:代理客户端根据直播间用户关系表对第一直播媒体流进行复制,本实施例中除了主要主用户的客户端C1之外,还有备份主用户客户端C2和仆用户客户端C3,所以复制两份第一直播媒体流。
S59:代理客户端将所述第一直播媒体流发送给客户端C1。另外,还包括:所述代理客户端根据客户端C1的播放时间来调整第一直播媒体流的时间戳。
S60:代理客户端将所述第一直播媒体流发送给客户端C2。另外,还包括:所述代理客户端根据客户端C2的播放时间来调整第一直播媒体流的时间戳。
S61:代理客户端将所述第一直播媒体流发送给客户端C3。另外,还包括:所述代理客户端根据客户端C3的播放时间来调整第一直播媒体流的时间戳。
具体地,S59至S61中代理客户端调整第一直播媒体流的时间戳的过程参见上述实施例的描述,此处不详细赘述。
此外,本实施例中还包括主要主用的客户端C1退出直播间流程,该过程与前世实施例一中客户端C1退出直播间的流程相似,具体地,如图8所示。
S62至S65与实施例一中的S40至S43相同。
S66:代理服务器选择备份主用户客户端C2作为新的主要主用户,并将客户端C2的角色从备份主用户变更为主要主用户,同时更新“直播间用户关系表”中关于客户端C2的记录。
S67至S73与实施例一中的S48至S53相同。
S74:媒体服务器向代理服务器发送第三直播媒体流,所述第三直播媒体流是发送给客户端C3的媒体流,且来源于内容源,此时所述客户端C3的角色从仆用户变更为备份主用户。
S75:代理服务器接收到所述第三直播媒体流之后,由于客户端C3的角色已经变更为备份主用户,所以以GOP为单位在本地缓存所述第三直播媒体流,并使用对齐算法对齐所述第二直播媒体流和所述第三直播媒体流。
在客户端C1退出直播间的流程中,代理服务器将向直播间中的客户端(如客户端C2)发送的第一直播媒体流切换为第二直播媒体流后,媒体服务器持续通过代理服务器向客户端C2发送第二直播媒体流,切换后,代理服务器将持续接收的该第二直播媒体流分发给代理客户端,详见后续步骤。
S76:媒体服务器实时地向代理服务器送第二直播媒体流,所述第二直播媒体流是发送给客户端C2的媒体流,且来源与内容源,此时所述客户端C2的角色从备份主用户变更为主要主用户。
S77:代理服务器接收到所述第二直播媒体流之后,以GOP为单位在本地缓存所述第二直播媒体流,并使用对齐算法对齐所述第一直播媒体流和所述第二直播媒体流。
S78:代理服务器将所述第二直播媒体流发送给代理客户端。
S79:代理客户端接收代理服务器发送的第二直播媒体流后,以GOP为单位在本地缓存所述第二直播媒体流。
S80:代理客户端根据“直播间用户关系表”复制和分发所述第二直播媒体流,本实施例 中将第二直播媒体流复制一份,并准备发送给直播间中的角色为备份主用户的客户端C3。
S81:代理客户端将本地缓存的第二直播媒体流发送给客户端C2。另外,还包括:代理客户端根据客户端C2接收到媒体流的视频帧的时间来调整第二直播媒体流中的时间戳。
S82:代理客户端将本地缓存的第二直播媒体流发送给客户端C3。另外,还包括:代理客户端根据客户端C3接收到媒体流的视频帧的时间来调整第二直播媒体流中的时间戳。
本实施例提供的方法,当主要主用户的客户端C1退出直播间时,代理服务器将新的主要主用户的客户端C2的直播媒体流发送给代理客户端,再由代理客户端将该新的直播媒体流发送给客户端C2和C3,从而保证当直播间中主要主用户退出时,不影响直播间中的其他用户的观看体验。
本实施例中,代理服务器获取媒体服务器发送的多份直播媒体流,每份直播媒体流对应一个客户端的媒体请求消息,但是代理服务器在向代理客户端发送媒体流时,仅仅将角色为主要主用户的客户端对应的一份直播媒体流发送给代理客户端,对于获取的角色为备份主用户的直播媒体流则缓存在代理服务器本地,对于获取的仆用户的直播媒体流不缓存,直接丢弃,从而使得代理服务器只耗费一份带宽来传输直播媒体流给代理客户端,节约了代理服务器与代理客户端之间的WAN网资源。在代理客户端侧,代理客户端接收到代理服务器发送的直播媒体流后,复制和分发该直播媒体流给直播间中的所有客户端,并且在发送该直播媒体流之前调整每个客户端的时间戳,使得通过该代理客户端进入直播间的所有用户可以“同时”观看直播内容。
另外,本实施例提供的方法还包括客户端C2和客户端C1同时请求退出直播间,具体地,客户端C2请求退出直播间的过程与前述客户端C1退出直播间的方法过程相似。
具体地,首先,是客户端C1请求并退出直播间的过程,该过程与前述S62至S73相同(如图8所示),不详细赘述。其中,在客户端C1退出直播间时,客户端C2的角色从备份主用户变更为主要主用户,客户端C3的角色从仆用户变更为备份主用户。
在S73之后是客户端C2请求并退出直播间的过程,具体包括:客户端C2向代理客户端发送退出直播间请求消息,代理客户端接收后标记客户端C2的角色为退出用户,并转发该退出直播间请求消息给代理服务器,代理服务器接收后在“直播间用户关系表”中刷新客户端C2的角色为退出用户。此时客户端C3仍然在直播间中并获取直播媒体流,代理服务器接收媒体服务器发送的第三直播媒体流,所述第三直播媒体流是发送给客户端C3的媒体流。此时客户端C3的角色从备份主用户变更为主要主用户,所以代理服务器以GOP为单位在本地缓存所述第三直播媒体流。
由于直播间中客户端C3仍然在观看直播内容,所以代理服务器需要将直播媒体流切换到所述第三直播媒体流,并对齐所述第三直播媒体流和第一直播媒体流。所述代理服务器将所述第三直播媒体流发送给代理客户端,所述代理客户端接收到该第三直播媒体流之后,缓存并将该第三直播媒体流发送给客户端C3,并且在代理客户端发送所述第三直播媒体流时调整时间戳,使得发送给客户端C3的第三直播媒体流可以无缝地对接之前的媒体流,从而使得客户端C1和C2退出时对客户端C3无影响,从而保证了仍然在直播间的客户端C3观看媒体内容的流畅性。
另外还包括:在转发客户端C2的退出直播间响应消息时,代理服务器和代理客户端在“直播间用户关系表”中删除关于客户端C2的记录,以便实时更新直播间中客户端的信息。
需要说明的是,上述实施例一和实施例二,均是对以通过同一代理客户端进入到直播间中的所有客户端而言,代理服务器标识各个客户端的角色并分发直播媒体流。另外,还有一 种情况是,由多个代理客户端接入同一个代理服务器,对于该代理服务器进入同一直播间的所有客户端而言,代理服务器为通过多个代理客户端进入所述直播间的所有客户端统一地标识用户角色,例如在三个代理客户端接入同一个代理服务器的情况下,对于直播间的所有客户端,统一地标识主用户和仆用户,并根据标识的角色情况,向代理客户端发送直播媒体流。进一步地,代理服务器标识用户角色并向每个代理客户端发送直播媒体流,以及每个代理客户端将该直播媒体流复制分发给其接入的所有客户端的过程与前述实施例一和实施例二的方法相同,此处不再赘述。
本申请实施例提供的视频直播双边代理技术,利用代理客户端和代理服务器,其中,代理服务器用于根据直播间请求消息标识各个客户端的角色,并仅发送一份角色为主用户的直播媒体流给代理客户端,代理客户端接收该主用户的直播媒体流后复制和分发给其接入的所有客户端,本方法有效地减少了代理服务器与代理客户端之间发送媒体流的流量,降低了出口带宽,节约了WAN网的资源开销。
另外,本方法不需要媒体服务器配置单独的鉴权给客户端,直接通过代理客户端统一转发,所以还进一步地降低运维成本。
下面介绍与本申请上述方法实施例所对应的装置和硬件设备实施例。
参见图9,为本申请一实施例提供的一种媒体流发送装置的结构示意图,该装置可以是上述实施例所述的代理服务器,或者还可以是代理客户端。
进一步地,该装置包括:接收单元901、处理单元902和发送单元903,此外还可以包括其它功能模块或单元,比如存储单元等。其中,所述装置可以为服务器,用于执行上述实施例所述的媒体流发送方法,例如为经过同一代理客户端进入直播间的至少两个客户端提供直播媒体流。
具体地,当所述装置作为代理服务器时,接收单元901用于分别接收来自同一代理客户端发送的用于请求进入直播间的第一直播间请求消息和第二直播间请求消息,其中所述第一直播间请求消息来自第一客户端,所述第二直播间请求消息来自第二客户端;所述接收单元901还用于分别接收媒体服务器通过代理服务器向所述第一客户端发送的第一直播媒体流和向所述第二客户端发送的第二直播媒体流;处理单元902用于根据所述第一直播间请求消息确定所述第一客户端的角色,并根据所述第二直播间请求消息确定所述第二客户端的角色;发送单元903用于在确定所述第一客户端的角色为主用户、所述第二客户端的角色为仆用户的情况下,仅将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。
其中,所述第一直播间请求消息中包括代理客户端的标识,和,所述第二直播间请求消息中包括所述代理客户端的标识;处理单元902还用于根据所述第一直播间请求消息包括的所述代理客户端的标识,和,所述第二直播间请求消息包括的所述代理客户端的标识,确定所述第一直播间请求消息和所述第二直播间请求消息来自同一代理客户端。
可选的,在本实施例的一种具体的实现方式中,处理单元902具体用于确定在接收到所述第二直播间请求消息时,所述直播间中是否存在通过所述代理客户端进入所述直播间的角色为主用户的客户端;如果存在,则确定所述第二客户端的角色是仆用户。反之,如果所述直播间中不存在,则确定所述第二客户端的角色是主用户。
可选的,在本实施例的另一种具体的实现方式中,接收单元901还用于将所述第一直播媒体流发送给所述代理客户端之后,接收代理客户端发送的退出直播间请求消息,所述退出直播间请求消息用于请求所述第一客户端退出所述直播间;处理单元902还用于在确定将所述第二客户端作为新的主用户时,将所述第二客户端的角色从所述仆用户变更为主用户,以 及将向所述第二客户端发送的第一直播媒体流切换为所述第二直播媒体流。
可选的,在本实施例的又一种具体的实现方式中,向所述第二客户端发送的所述第一直播媒体流的最后一帧与向所述第二客户端发送的所述第二直播媒体流的第一帧为相邻帧;所述处理单元902还用于根据所述第一直播媒体流和所述第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧;根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧,并将所述第一切换帧和所述第二切换帧分别作为向所述第二客户端发送的所述第一直播媒体流的最后一帧与向所述第一客户端发送的所述第二直播媒体流的第一帧;发送单元903还用于在确定所述第一切换帧和所述第二切换帧之后,还用于将所述第一客户端的退出直播间请求消息转发给所述媒体服务器。
可选的,在本实施例的又一种具体的实现方式中,处理单元902具体用于在接收到所述第二直播间请求消息时,判断通过所述代理客户端进入所述直播间的角色为主用户的客户端的数量是否达到预设上限,所述预设上限大于等于2;如果达到所述预设上限,则确定所述第二客户端的角色是仆用户。
对应地。如果所述主用户的客户端的数量不为0,且没有达到所述预设上限,则处理单元902确定所述第二客户端的角色是备份主用户。
可选的,在本实施例的又一种具体的实现方式中,在所述第一客户端是主要主用户,所述第二客户端是仆用户的情况下,接收单元901还用于接收来自所述第一客户端的退出直播间请求消息;处理单元902还用于在确定将所述第二客户端作为新的备份主用户时,将所述第二客户端的角色从所述仆用户变更为备份主用户;存储单元用于以GOP为单位缓存接收的所述第二直播媒体流。
可选的,在本实施例的又一种具体的实现方式中,在所述第一客户端是主要主用户,所述第二客户端是备份主用户的情况下,所述存储单元还用于以GOP为单位缓存接收的所述第二直播媒体流;所述处理单元902还用于根据所述第一直播媒体流和缓存的所述第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧。
可选的,在本实施例的又一种具体的实现方式中,接收单元901还用于接收来自所述第一客户端的退出直播间请求消息;处理单元902还用于在确定将所述第二客户端作为新的主要主用户时,以及,根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧;根据所述第一切换帧和所述第二切换帧将向所述第二客户端发送的第一直播媒体流切换为所述第二直播媒体流;其中,向所述第二客户端发送的所述第一直播媒体流的最后一帧为所述第一切换帧,向所述第一客户端发送的所述第二直播媒体流的第一帧为所述第二切换帧。
可选的,在本实施例的又一种具体的实现方式中,存储单元用于以GOP为单位缓存所述第一直播媒体流和所述第二直播媒体流。
另外,当所述装置作为代理客户端时,接收单元901用于分别接收第一客户端发送的第一直播间请求消息,和,第二客户端发送的第二直播间请求消息;发送单元903用于通过代理服务器向媒体服务器发送所述第一直播间请求消息和所述第二直播间请求消息;接收单元901还用于接收所述代理服务器发送的第一直播媒体流,所述第一直播媒体流是所述媒体服务器通过所述代理服务器向第一客户端发送的媒体流,所述第一客户端的角色为主用户,所述第二客户端的角色为仆用户;发送单元903还用于将所述第一直播媒体流发送给所述第一 客户端和所述第二客户端。
进一步地,处理单元902用于在发送所述第一直播间请求消息之前,将代理客户端的标识添加到所述第一直播间请求消息中,和,在发送所述第二直播间请求消息之前,将所述代理客户端的标识添加到所述第二直播间请求消息中。
还包括:存储单元用于以GOP为单位缓存所述第一直播媒体流。
可选的,在本实施例的一种具体的实现方式中,处理单元902还用于在接收到所述第一直播间请求消息的情况下,将所述第一客户端的角色标记为工作;在接收到所述第二直播间请求消息的情况下,将所述第二客户端的角色标记为工作;在接收到所述退出直播间请求消息的情况下,将所述第一客户端的角色标记为退出。
可选的,在本实施例的一种具体的实现方式中,处理单元902还用于在将所述第一直播媒体流发送给所述第二客户端之前,调整所述第一直播媒体流的时间戳,使得调整后的时间戳满足:向所述第二客户端发送的所述第一直播媒体流的第一帧的时间戳为0,并且,向所述第二客户端发送的所述第一直播媒体流的相邻帧的时间戳连续。
可选的,在本实施例的一种具体的实现方式中,在所述第一客户端请求退出直播间的情况下,接收单元901还用于接收所述代理服务器发送的第二直播媒体流,所述第二直播媒体流是所述媒体服务器通过所述代理客户端发送给第二客户端的媒体流,所述第二客户端是角色从仆用户变更为主用户的客户端;发送单元903还用于将所述第二直播媒体流发送给所述第二客户端。
可选的,在本实施例的一种具体的实现方式中,所述处理单元902还用于将所述第二直播媒体流发送给所述第二客户端之前,调整所述第二直播媒体流的时间戳,使得调整后的时间戳满足:向所述第二客户端发送的所述第二直播媒体流的第一帧的时间戳与向所述第二客户端发送的所述第一直播媒体流的最后一帧的时间戳连续。
在具体的硬件实现中,如图10所示,本申请还提供了一种网络设备,该网络设备可以是前述方法实施例中的代理服务器,或者是代理客户端,或者还可以CDN系统里的其他设备或装置。
具体地,该网络设备包括:收发器10、处理器20和存储器30,该网络设备还可以包括更多或更少的部件,或者组合某些部件,或者不同的部件布置,本申请对此不进行限定。
其中,收发器10用于接收和发送请求消息、响应消息、直播媒体流等,并与网络中的其他设备(客户端、媒体服务器等)进行数据传输。进一步地,收发器10可以包括接收机1001、发射机1002与天线1003等部件,或者还可以包括收发模块,进一步地,所述收发模块可以包括无线局域网(wireless local area network,WLAN)模块、蓝牙模块、基带(base band)模块等通信模块,以及所述通信模块对应的射频(radio frequency,RF)电路,用于进行无线局域网络通信、蓝牙通信、红外线通信及/或蜂窝式通信系统通信,例如宽带码分多重接入(wideband code division multiple access,WCDMA)及/或高速下行封包存取(high speed downlink packet access,HSDPA)。所述收发模块用于控制网络设备中的各组件的通信,并且可以支持直接内存存取(direct memory access)。
处理器20为网络设备的控制中心,利用各种接口和线路连接整个设备的各个部分,通过运行或执行存储在存储器30内的软件程序和/或单元,以及调用存储在存储器30内的数据,以执行网络设备的各种功能和各种功能和/或处理数据。
进一步地,处理器20可以由集成电路(Integrated Circuit,IC)组成,例如可以由单颗封装的IC所组成,也可以由连接多颗相同功能或不同功能的封装IC而组成。举例来说, 处理器可以仅包括中央处理器(Central Processing Unit,CPU),也可以是GPU、数字信号处理器(Digital Signal Processor,DSP)、及收发器中的控制芯片(例如基带芯片)的组合。
存储器30可以包括易失性存储器(volatile memory),例如随机存取内存(Random Access Memory,RAM);还可以包括非易失性存储器(non-volatile memory),例如快闪存储器(flash memory),硬盘(Hard Sisk Drive,HDD)或固态硬盘(Solid-State Drive,SSD);存储器还可以包括上述种类的存储器的组合。所述存储器中可以存储有程序或代码,处理器802通过执行所述程序或代码可以实现所述通信设备的功能。
在本实施例中,当所述网络设备作为代理服务器时,前述图9所示装置实施例中的接收单元901和发送单元903的功能可以由收发器10来实现,或者由处理器20控制的收发器10实现;所述处理单元902所要实现的功能则可以由处理器20实现,所述存储单元的功能可以由存储器30实现。
当所述网络设备作为代理客户端时,前述图9所示装置实施例中的接收单元901和发送单元903的功能可以由收发器10来实现,或者由处理器20控制的收发器10实现;所述处理单元902所要实现的功能则可以由处理器20实现,所述存储单元的功能可以由存储器30实现。
另外,本申请实施例还提供一种媒体流发送系统。该系统包括上述实施例图9所示的媒体流发送装置或图10所示的网络设备,还包括多个客户端、RDC、EDC和内容源等设备,以用于实现上述各个实施例中的媒体流发送方法。
可选的,所述媒体流发送系统为视频直播系统,例如CDN系统。
此外,本申请还提供一种计算机存储介质,其中,该计算机存储介质可存储有程序,该程序执行时可包括本申请提供的内容发送方法、内容接收方法的各实施例中的部分或全部步骤。所述的存储介质可为磁碟、光盘、只读存储记忆体ROM或随机存储记忆体RAM等。
在上述实施例中,可以全部或部分通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机加载和执行所述计算机程序时,全部或部分地产生按照本申请上述各个实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络或者其他可编程装置。
所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网络节点、计算机、服务器或数据中心通过有线或无线方式向另一个站点、计算机或服务器进行传输。
本说明书中各个实施例之间相同相似的部分互相参见即可。尤其,对于一种媒体流发送装置的实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例中的说明即可。
本领域的技术人员可以清楚地了解到本发明实施例中的技术可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本发明实施例中的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例或者实施例的某些部分所述的方法。
本说明书中各个实施例之间相同相似的部分互相参见即可。尤其,对于一种同步载频信号发送装置、接收装置的实施例而言,由于其基本相似于方法实施例,所以描述的比较简单, 相关之处参见方法实施例中的说明即可。
此外,在本申请的描述中,除非另有说明,“多个”是指两个或多于两个。另外,为了便于清楚描述本申请实施例的技术方案,在本申请的实施例中,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。
以上所述的本申请实施方式并不构成对本申请保护范围的限定。

Claims (37)

  1. 一种媒体流发送方法,其特征在于,所述方法为进入直播间的客户端提供直播媒体流,所述方法包括:
    代理服务器分别接收同一代理客户端发送的用于请求进入直播间的第一直播间请求消息和第二直播间请求消息,其中所述第一直播间请求消息来自第一客户端,所述第二直播间请求消息来自第二客户端;
    所述代理服务器分别接收媒体服务器通过所述代理服务器向所述第一客户端发送的第一直播媒体流和向所述第二客户端发送的第二直播媒体流;
    所述代理服务器根据所述第一直播间请求消息确定所述第一客户端的角色,并根据所述第二直播间请求消息确定所述第二客户端的角色;
    所述代理服务器在确定所述第一客户端的角色为主用户、所述第二客户端的角色为仆用户的情况下,仅将所述第一直播媒体流发送给所述代理客户端,以使所述代理客户端将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。
  2. 根据权利要求1所述的方法,其特征在于,所述第一直播间请求消息中包括代理客户端的标识,和,所述第二直播间请求消息中包括所述代理客户端的标识;
    所述方法还包括:所述代理服务器根据所述第一直播间请求消息包括的所述代理客户端的标识,和,所述第二直播间请求消息包括的所述代理客户端的标识,确定所述第一直播间请求消息和所述第二直播间请求消息来自同一代理客户端。
  3. 根据权利要求1或2所述的方法,其特征在于,所述代理服务器根据所述第二直播间请求消息确定所述第二客户端的角色,包括:
    所述代理服务器确定在接收到所述第二直播间请求消息时,所述直播间中是否存在通过所述代理客户端进入所述直播间的角色为主用户的客户端;
    如果存在,则确定所述第二客户端的角色是仆用户。
  4. 根据权利要求3所述的方法,其特征在于,所述代理服务器将所述第一直播媒体流发送给所述代理客户端之后,还包括:
    所述代理服务器接收代理客户端发送的退出直播间请求消息,所述退出直播间请求消息用于请求所述第一客户端退出所述直播间;
    所述代理服务器在确定将所述第二客户端作为新的主用户时,将所述第二客户端的角色从所述仆用户变更为主用户;
    所述代理服务器将向所述第二客户端发送的第一直播媒体流切换为所述第二直播媒体流。
  5. 根据权利要求4所述的方法,其特征在于,所述代理服务器向所述第二客户端发送的所述第一直播媒体流的最后一帧与向所述第二客户端发送的所述第二直播媒体流的第一帧为相邻帧;
    所述代理服务器将向所述第二客户端发送的第一直播媒体流切换为所述第二直播媒体流之前,还包括:
    所述代理服务器根据所述第一直播媒体流和所述第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧;
    所述代理服务器根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播 媒体流和所述第二直播媒体流的第一切换帧和第二切换帧,并将所述第一切换帧和所述第二切换帧分别作为向所述第二客户端发送的所述第一直播媒体流的最后一帧与向所述第一客户端发送的所述第二直播媒体流的第一帧;
    所述代理服务器在确定所述第一切换帧和所述第二切换帧之后还包括,所述代理服务器将来自所述第一客户端的退出直播间请求消息转发给所述媒体服务器。
  6. 根据权利要求1或2所述的方法,其特征在于,根据所述第二直播间请求消息确定第二客户端的角色,包括:
    所述代理服务器在接收到所述第二直播间请求消息时,判断通过所述代理客户端进入所述直播间的角色为主用户的客户端的数量是否达到预设上限,所述预设上限大于等于2;
    如果达到所述预设上限,则确定所述第二客户端的角色是仆用户。
  7. 根据权利要求6所述的方法,其特征在于,还包括:
    如果所述直播间中角色为主用户的客户端的数量不为0,且没有达到所述预设上限,则确定所述第二客户端的角色是备份主用户。
  8. 根据权利要求6所述的方法,其特征在于,在所述第一客户端是主要主用户,所述第二客户端是仆用户的情况下,还包括:
    所述代理服务器接收来自所述第一客户端的退出直播间请求消息;
    所述代理服务器在确定将所述第二客户端作为新的备份主用户时,将所述第二客户端的角色从所述仆用户变更为备份主用户;
    所述代理服务器以图像组GOP为单位缓存接收的所述第二直播媒体流。
  9. 根据权利要求7所述的方法,其特征在于,在所述第一客户端是主要主用户,所述第二客户端是备份主用户的情况下,还包括:
    所述代理服务器以GOP为单位缓存接收的所述第二直播媒体流;
    所述代理服务器根据所述第一直播媒体流和缓存的所述第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧。
  10. 根据权利要求9所述的方法,其特征在于,还包括:
    所述代理服务器接收来自所述第一客户端的退出直播间请求消息;
    所述代理服务器在确定将所述第二客户端作为新的主要主用户时,将所述第二客户端的角色从所述备份主用户变更为主要主用户;
    所述代理服务器根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧;
    所述代理服务器根据所述第一切换帧和所述第二切换帧将向所述第二客户端发送的第一直播媒体流切换为所述第二直播媒体流,其中,所述代理服务器向所述第二客户端发送的所述第一直播媒体流的最后一帧为所述第一切换帧,向所述第一客户端发送的所述第二直播媒体流的第一帧为所述第二切换帧。
  11. 根据权利要求1-10任一项所述的方法,其特征在于,还包括:
    所述代理服务器以GOP为单位缓存所述第一直播媒体流。
  12. 一种媒体流发送方法,其特征在于,所述方法为进入直播间的客户端提供直播媒体流,所述方法包括:
    代理客户端分别接收第一客户端发送的用于请求进入直播间的第一直播间请求消息,和,第二客户端发送的用于请求进入所述直播间的第二直播间请求消息;
    所述代理客户端通过代理服务器向媒体服务器发送所述第一直播间请求消息和所述第二直播间请求消息;
    所述代理客户端接收所述代理服务器发送的第一直播媒体流,所述第一直播媒体流是所述媒体服务器通过所述代理服务器向所述第一客户端发送的媒体流,所述第一客户端的角色为主用户,所述第二客户端的角色为仆用户;
    所述代理客户端将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。
  13. 根据权利要求12所述的方法,其特征在于,
    所述代理客户端通过代理服务器向媒体服务器发送所述第一直播间请求消息之前还包括:所述代理客户端将所述代理客户端的标识添加到所述第一直播间请求消息中;
    所述代理客户端通过代理服务器向媒体服务器发送所述第二直播间请求消息之前还包括:所述代理客户端将所述代理客户端的标识添加到所述第二直播间请求消息中。
  14. 根据权利要求12或13所述的方法,其特征在于,所述代理客户端接收所述代理服务器发送的第一直播媒体流之后,还包括:
    所述代理客户端以图像组GOP为单位缓存所述第一直播媒体流。
  15. 根据权利要求12-14任一项所述的方法,其特征在于,所述代理客户端将所述第一直播媒体流发送给所述第二客户端之前,还包括:
    所述代理客户端调整所述第一直播媒体流的时间戳,使得调整后的时间戳满足:所述代理客户端向所述第二客户端发送的所述第一直播媒体流的第一帧的时间戳为0,并且,向所述第二客户端发送的所述第一直播媒体流的相邻帧的时间戳连续。
  16. 根据权利要求12-15任一项所述的方法,其特征在于,在所述第一客户端请求退出直播间的情况下,还包括:
    所述代理客户端接收所述代理服务器发送的第二直播媒体流,所述第二直播媒体流是所述媒体服务器通过所述代理客户端发送给第二客户端的媒体流,所述第二客户端是角色从仆用户变更为主用户的客户端;
    所述代理客户端将所述第二直播媒体流发送给所述第二客户端。
  17. 根据权利要求16所述的方法,其特征在于,所述代理客户端将所述第二直播媒体流发送给所述第二客户端之前,还包括:
    所述代理客户端调整所述第二直播媒体流的时间戳,使得调整后的时间戳满足:所述代理客户端向所述第二客户端发送的所述第二直播媒体流的第一帧的时间戳与向所述第二客户端发送的所述第一直播媒体流的最后一帧的时间戳连续。
  18. 一种媒体流发送装置,其特征在于,所述装置包括:
    接收单元,用于分别接收来自同一代理客户端发送的用于请求进入直播间的第一直播间请求消息和第二直播间请求消息,其中所述第一直播间请求消息来自第一客户端,所述第二直播间请求消息来自第二客户端;
    所述接收单元,还用于分别接收媒体服务器通过代理服务器向所述第一客户端发送的第一直播媒体流和向所述第二客户端发送的第二直播媒体流;
    处理单元,用于根据所述第一直播间请求消息确定所述第一客户端的角色,并根据所述第二直播间请求消息确定所述第二客户端的角色;
    发送单元,用于在确定所述第一客户端的角色为主用户、所述第二客户端的角色为仆用户的情况下,仅将所述第一直播媒体流发送给所述代理客户端,以使所述代理客户端将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。
  19. 根据权利要求18所述的装置,其特征在于,所述第一直播间请求消息中包括代理客户端的标识,和,所述第二直播间请求消息中包括所述代理客户端的标识;
    处理单元,还用于根据所述第一直播间请求消息包括的所述代理客户端的标识,和,所述第二直播间请求消息包括的所述代理客户端的标识,确定所述第一直播间请求消息和所述第二直播间请求消息来自同一代理客户端。
  20. 根据权利要求18或19所述的装置,其特征在于,
    所述处理单元,具体用于确定在接收到所述第二直播间请求消息时,所述直播间中是否存在通过所述代理客户端进入所述直播间的角色为主用户的客户端;如果存在,则确定所述第二客户端的角色是仆用户。
  21. 根据权利要求20所述的装置,其特征在于,
    所述接收单元,还用于将所述第一直播媒体流发送给所述代理客户端之后,接收代理客户端发送的退出直播间请求消息,所述退出直播间请求消息用于请求所述第一客户端退出所述直播间;
    所述处理单元,还用于在确定将所述第二客户端作为新的主用户时,将所述第二客户端的角色从所述仆用户变更为主用户;以及将向所述第二客户端发送的第一直播媒体流切换为所述第二直播媒体流。
  22. 根据权利要求21所述的装置,其特征在于,向所述第二客户端发送的所述第一直播媒体流的最后一帧与向所述第二客户端发送的所述第二直播媒体流的第一帧为相邻帧;
    所述处理单元,还用于根据所述第一直播媒体流和所述第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧;根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧,并将所述第一切换帧和所述第二切换帧分别作为向所述第二客户端发送的所述第一直播媒体流的最后一帧与向所述第一客户端发送的所述第二直播媒体流的第一帧;
    所述发送单元,还用于在确定所述第一切换帧和所述第二切换帧之后,将来自所述第一客户端的退出直播间请求消息转发给所述媒体服务器。
  23. 根据权利要求18或19所述的装置,其特征在于,
    所述处理单元,具体用于在接收到所述第二直播间请求消息时,判断通过所述代理客户端进入所述直播间的角色为主用户的客户端的数量是否达到预设上限,所述预设上限大于等于2;如果达到所述预设上限,则确定所述第二客户端的角色是仆用户。
  24. 根据权利要求23所述的装置,其特征在于,
    所述处理单元,还用于在所述直播间中角色为主用户的客户端的数量不为0,且没有达到所述预设上限的情况下,确定所述第二客户端的角色是备份主用户。
  25. 根据权利要求23所述的装置,其特征在于,还包括存储单元,在所述第一客户端是主要主用户,所述第二客户端是仆用户的情况下,
    所述接收单元,还用于接收来自所述第一客户端的退出直播间请求消息;
    所述处理单元,还用于在确定将所述第二客户端作为新的备份主用户时,将所述第二客户端的角色从所述仆用户变更为备份主用户;
    所述存储单元,用于以图像组GOP为单位缓存接收的所述第二直播媒体流。
  26. 根据权利要求24所述的装置,其特征在于,还包括存储单元,在所述第一客户端是主要主用户,所述第二客户端是备份主用户的情况下,
    所述存储单元,用于以GOP为单位缓存接收的所述第二直播媒体流;
    所述处理单元,还用于根据所述第一直播媒体流和缓存的所述第二直播媒体流识别分别属于所述第一直播媒体流和所述第二直播媒体流的第一I帧和第二I帧,所述第一I帧和所述第二I帧为相同视频帧。
  27. 根据权利要求26所述的装置,其特征在于,
    所述接收单元,还用于接收来自所述第一客户端的退出直播间请求消息;
    所述处理单元,还用于在确定将所述第二客户端作为新的主要主用户时,将所述第二客户端的角色从所述备份主用户变更为主要主用户,以及,根据所述第一I帧和所述第二I帧确定相邻的且分别属于所述第一直播媒体流和所述第二直播媒体流的第一切换帧和第二切换帧;根据所述第一切换帧和所述第二切换帧将向所述第二客户端发送的第一直播媒体流切换为所述第二直播媒体流;
    其中,向所述第二客户端发送的所述第一直播媒体流的最后一帧为所述第一切换帧,向所述第一客户端发送的所述第二直播媒体流的第一帧为所述第二切换帧。
  28. 根据权利要求18-27任一项所述的装置,其特征在于,还包括:
    存储单元,用于以GOP为单位缓存所述第一直播媒体流。
  29. 一种媒体流发送装置,其特征在于,所述装置包括:
    接收单元,用于分别接收第一客户端发送的用于请求进入直播间的第一直播间请求消息,和,第二客户端发送的用于请求进入所述直播间的第二直播间请求消息;
    发送单元,用于通过代理服务器向媒体服务器发送所述第一直播间请求消息和所述第二直播间请求消息;
    所述接收单元,还用于接收所述代理服务器发送的第一直播媒体流,所述第一直播媒体流是所述媒体服务器通过所述代理服务器向所述第一客户端发送的媒体流,所述第一客户端的角色为主用户,所述第二客户端的角色为仆用户;
    所述发送单元,还用于将所述第一直播媒体流发送给所述第一客户端和所述第二客户端。
  30. 根据权利要求29所述的装置,其特征在于,还包括处理单元,
    所述处理单元,用于在发送所述第一直播间请求消息之前,将代理客户端的标识添加到所述第一直播间请求消息中,和,在发送所述第二直播间请求消息之前,将所述代理客户端的标识添加到所述第二直播间请求消息中。
  31. 根据权利要求29或30所述的装置,其特征在于,还包括存储单元,
    所述存储单元,用于以图像组GOP为单位缓存所述第一直播媒体流。
  32. 根据权利要求29-31任一项所述的装置,其特征在于,
    处理单元,用于将所述第一直播媒体流发送给所述第二客户端之前,调整所述第一直播媒体流的时间戳,使得调整后的时间戳满足:向所述第二客户端发送的所述第一直播媒体流的第一帧的时间戳为0,并且,向所述第二客户端发送的所述第一直播媒体流的相邻帧的时间戳连续。
  33. 根据权利要求29-32任一项所述的装置,其特征在于,在所述第一客户端请求退出直播间的情况下,
    所述接收单元,还用于接收所述代理服务器发送的第二直播媒体流,所述第二直播媒体流是所述媒体服务器通过所述代理客户端发送给第二客户端的媒体流,所述第二客户端是角色从仆用户变更为主用户的客户端;
    所述发送单元,还用于将所述第二直播媒体流发送给所述第二客户端。
  34. 根据权利要求33所述的装置,其特征在于,
    所述处理单元,还用于将所述第二直播媒体流发送给所述第二客户端之前,调整所述第二直播媒体流的时间戳,使得调整后的时间戳满足:向所述第二客户端发送的所述第二直播媒体流的第一帧的时间戳与向所述第二客户端发送的所述第一直播媒体流的最后一帧的时间戳连续。
  35. 一种媒体流发送系统,其特征在于,所述系统包括至少一个客户端、代理客户端、代理服务器和媒体服务器,其中每个所述客户端通过所述代理客户端接入直播间;
    所述代理客户端用于执行如权利要求12至17任一项所述媒体流发送方法;
    所述代理服务器用于执行如权利要求1至11任一项所述媒体流发送方法。
  36. 一种网络设备,包括处理器,所述处理器与存储器耦合,其特征在于,
    所述存储器,用于存储指令;
    所述处理器,用于执行所述存储器中的指令,使得所述网络设备执行如权利要求1至17中任一项所述的方法。
  37. 一种计算机可读存储介质,所述存储介质中存储有指令,其特征在于,
    当所述指令被运行时,实现如权利要求1至17中任一项所述的方法。
PCT/CN2020/086335 2019-04-23 2020-04-23 一种媒体流发送方法、装置、设备和系统 WO2020216277A1 (zh)

Priority Applications (5)

Application Number Priority Date Filing Date Title
KR1020217021677A KR102457526B1 (ko) 2019-04-23 2020-04-23 미디어 스트림 송신 방법, 장치, 시스템, 및 디바이스
JP2021542510A JP7259056B2 (ja) 2019-04-23 2020-04-23 メディアストリーム送信方法、装置、システム、およびデバイス
EP20796076.6A EP3890265B1 (en) 2019-04-23 2020-04-23 Media stream sending method, apparatus, device and system
US17/369,580 US11330028B2 (en) 2019-04-23 2021-07-07 Media stream sending method, apparatus, system, and device
US17/675,236 US11848973B2 (en) 2019-04-23 2022-02-18 Media stream sending method, apparatus, system and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910330890.5 2019-04-23
CN201910330890.5A CN111835697B (zh) 2019-04-23 2019-04-23 一种媒体流发送方法、装置、设备和系统

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/369,580 Continuation US11330028B2 (en) 2019-04-23 2021-07-07 Media stream sending method, apparatus, system, and device

Publications (1)

Publication Number Publication Date
WO2020216277A1 true WO2020216277A1 (zh) 2020-10-29

Family

ID=72912479

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/086335 WO2020216277A1 (zh) 2019-04-23 2020-04-23 一种媒体流发送方法、装置、设备和系统

Country Status (6)

Country Link
US (2) US11330028B2 (zh)
EP (1) EP3890265B1 (zh)
JP (1) JP7259056B2 (zh)
KR (1) KR102457526B1 (zh)
CN (1) CN111835697B (zh)
WO (1) WO2020216277A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114760485B (zh) * 2021-01-08 2023-09-26 深圳市酷看文化传播有限公司 视频轮播方法、系统及相关设备
CN113535063A (zh) * 2021-08-12 2021-10-22 腾讯音乐娱乐科技(深圳)有限公司 直播页面切换方法、视频页面切换方法、电子设备及存储介质
US11824914B1 (en) * 2022-11-15 2023-11-21 Motorola Solutions, Inc. System and method for streaming media to a public safety access point without incurring additional user costs

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105307010A (zh) * 2015-11-14 2016-02-03 华中科技大学 一种云视频直播平台的视频上传系统及方法
CN105763832A (zh) * 2014-12-16 2016-07-13 中国移动通信集团公司 一种视频互动、控制方法及装置
CN107332894A (zh) * 2017-06-23 2017-11-07 广州市百果园信息技术有限公司 直播方法、装置及系统、服务器、存储介质
WO2018219048A1 (zh) * 2017-05-31 2018-12-06 华为技术有限公司 一种直播方法、系统以及相关设备
CN109005204A (zh) * 2017-06-07 2018-12-14 腾讯科技(深圳)有限公司 一种直播处理方法、装置及系统

Family Cites Families (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1063598A (ja) * 1996-08-22 1998-03-06 Nippon Telegr & Teleph Corp <Ntt> マルチキャスト通信方法及びマルチキャスト通信システムと、マルチキャスト通信用サーバ
US7031348B1 (en) * 1998-04-04 2006-04-18 Optibase, Ltd. Apparatus and method of splicing digital video streams
US6966009B1 (en) * 2001-08-28 2005-11-15 Tellabs Operations, Inc. System and method for aligning data in a network environment
US6842825B2 (en) * 2002-08-07 2005-01-11 International Business Machines Corporation Adjusting timestamps to preserve update timing information for cached data objects
JP2006352648A (ja) * 2005-06-17 2006-12-28 Nippon Telegr & Teleph Corp <Ntt> カメラ映像配信方法およびシステム
CN100563235C (zh) * 2006-01-09 2009-11-25 华为技术有限公司 互通功能网元、csi终端与ims终端互通系统及其方法
JP2008193500A (ja) * 2007-02-06 2008-08-21 Canon Inc データ送信装置及びデータ中継装置
JP5353277B2 (ja) * 2009-02-06 2013-11-27 日本電気株式会社 ストリーム信号伝送装置及び伝送方法
US8516253B1 (en) * 2010-01-18 2013-08-20 Viasat, Inc. Self-keyed protection of anticipatory content
JP2013058817A (ja) * 2011-09-06 2013-03-28 Onkyo Corp コンテンツ再生システム
CN102780916B (zh) * 2012-04-12 2015-03-18 天脉聚源(北京)传媒科技有限公司 一种视频直播流汇聚分发方法
CN104168300B (zh) * 2013-05-17 2017-06-27 中国电信股份有限公司 内容加速方法与系统
US9674251B2 (en) * 2013-06-17 2017-06-06 Qualcomm Incorporated Mediating content delivery via one or more services
EP3031218B1 (en) * 2013-08-09 2017-06-28 Sonova AG Hearing assistance system and method
US10044827B1 (en) * 2014-11-13 2018-08-07 Amazon Technologies, Inc. Trigger-based session service cache population
CN106302566B (zh) * 2015-05-12 2019-07-23 华为技术有限公司 直播媒体数据的方法、设备和系统
CN106502554B (zh) * 2015-09-08 2021-09-17 腾讯科技(深圳)有限公司 一种显示控制方法及装置
CN105141971B (zh) * 2015-09-16 2018-08-28 深圳市前海智媒网络科技有限公司 一种基于会话初始化协议实现直播的方法及系统
US20170134825A1 (en) * 2015-11-09 2017-05-11 Le Holdings (Beijing) Co., Ltd. Method and device for processing panoramic live broadcast video resources
CN105959772B (zh) * 2015-12-22 2019-04-23 合一网络技术(北京)有限公司 流媒体与字幕即时同步显示、匹配处理方法、装置及系统
JP6394620B2 (ja) * 2016-02-04 2018-09-26 日本電気株式会社 サーバ管理システム、サーバ、サーバ管理方法およびサービスプロセッサ
US20180012192A1 (en) * 2016-07-08 2018-01-11 Cisco Technology, Inc. User experiences in personal meeting rooms
CN107343220B (zh) * 2016-08-19 2019-12-31 北京市商汤科技开发有限公司 数据处理方法、装置和终端设备
CN106507161B (zh) * 2016-11-29 2019-11-15 腾讯科技(深圳)有限公司 视频直播方法及直播装置
US10687093B2 (en) * 2016-12-30 2020-06-16 Social Media Broadcaster, Inc. Social-media-based TV show production, distribution, and broadcast system
US10638192B2 (en) * 2017-06-19 2020-04-28 Wangsu Science & Technology Co., Ltd. Live streaming quick start method and system
CN107896337B (zh) * 2017-11-30 2020-12-22 广州酷狗计算机科技有限公司 信息推广方法、装置及存储介质
CN109639635B (zh) * 2018-11-05 2019-09-03 北京达佳互联信息技术有限公司 Cdn代理拉流方法、服务器、cdn及客户端
CN109547812A (zh) * 2019-01-22 2019-03-29 广州虎牙信息科技有限公司 一种直播方法、装置、移动终端与存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105763832A (zh) * 2014-12-16 2016-07-13 中国移动通信集团公司 一种视频互动、控制方法及装置
CN105307010A (zh) * 2015-11-14 2016-02-03 华中科技大学 一种云视频直播平台的视频上传系统及方法
WO2018219048A1 (zh) * 2017-05-31 2018-12-06 华为技术有限公司 一种直播方法、系统以及相关设备
CN109005204A (zh) * 2017-06-07 2018-12-14 腾讯科技(深圳)有限公司 一种直播处理方法、装置及系统
CN107332894A (zh) * 2017-06-23 2017-11-07 广州市百果园信息技术有限公司 直播方法、装置及系统、服务器、存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3890265A4 *

Also Published As

Publication number Publication date
US11848973B2 (en) 2023-12-19
KR20210100176A (ko) 2021-08-13
CN111835697A (zh) 2020-10-27
CN111835697B (zh) 2021-10-01
EP3890265B1 (en) 2023-04-26
EP3890265A4 (en) 2022-04-20
US20210337001A1 (en) 2021-10-28
JP7259056B2 (ja) 2023-04-17
US11330028B2 (en) 2022-05-10
EP3890265A1 (en) 2021-10-06
KR102457526B1 (ko) 2022-10-20
US20220174104A1 (en) 2022-06-02
JP2022517854A (ja) 2022-03-10

Similar Documents

Publication Publication Date Title
WO2020216279A1 (zh) 一种媒体流发送方法、装置和设备
WO2020216277A1 (zh) 一种媒体流发送方法、装置、设备和系统
US11095701B2 (en) Method and apparatus for providing adaptive streaming service
US9769236B2 (en) Combined broadcast and unicast delivery
JP5588517B2 (ja) データセグメントのオプションのブロードキャスト配信によるストリーミング
WO2017096935A1 (zh) 一种快速频道切换方法、服务器及iptv系统
US11863841B2 (en) Video playing control method and system
WO2017125017A1 (zh) 缓存内容的调整方法、装置及系统
US9813475B1 (en) Delivering a video stream
WO2015042962A1 (en) System and method of a link surfed http live streaming broadcasting system
US20220295127A1 (en) Consolidating content streams to conserve bandwidth
CN103841468A (zh) 实时流媒体数据传输方法
WO2020135562A1 (zh) 一种组播方法、装置、设备和计算机存储介质
KR20110129064A (ko) 콘텐트 가상 세그멘테이션 방법과, 이를 이용한 스트리밍 서비스 제공 방법 및 시스템
JP2018098569A (ja) データ配信システム、通信端末、及びプログラム
JP6009501B2 (ja) データセグメントのオプションのブロードキャスト配信によるストリーミング

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20796076

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020796076

Country of ref document: EP

Effective date: 20210629

ENP Entry into the national phase

Ref document number: 20217021677

Country of ref document: KR

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2021542510

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE