CN109246123A - Media stream capturing method and device - Google Patents

Media stream capturing method and device Download PDF

Info

Publication number
CN109246123A
CN109246123A CN201811157395.0A CN201811157395A CN109246123A CN 109246123 A CN109246123 A CN 109246123A CN 201811157395 A CN201811157395 A CN 201811157395A CN 109246123 A CN109246123 A CN 109246123A
Authority
CN
China
Prior art keywords
server
attribute
target
value
media stream
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811157395.0A
Other languages
Chinese (zh)
Other versions
CN109246123B (en
Inventor
吕现广
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Kugou Computer Technology Co Ltd
Original Assignee
Guangzhou Kugou Computer Technology Co Ltd
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 Guangzhou Kugou Computer Technology Co Ltd filed Critical Guangzhou Kugou Computer Technology Co Ltd
Priority to CN201811157395.0A priority Critical patent/CN109246123B/en
Publication of CN109246123A publication Critical patent/CN109246123A/en
Application granted granted Critical
Publication of CN109246123B publication Critical patent/CN109246123B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/1066Session management
    • H04L65/1069Session establishment or de-establishment
    • 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/65Network streaming protocols, e.g. real-time transport protocol [RTP] or real-time control protocol [RTCP]
    • 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/80Responding to QoS

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Business, Economics & Management (AREA)
  • General Business, Economics & Management (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a kind of media stream capturing method and devices, belong to network technique field.The described method includes: the target connection is for obtaining Media Stream from server, and the live streaming application is for providing multiple direct broadcast bands when starting live streaming in application, pre-establishing target connection;Detect the state of the target connection;When the state of target connection is down state, the target connection is re-established;When receiving the Media Stream acquisition instruction to any direct broadcast band, is connected based on the target, the Media Stream of the direct broadcast band is obtained from the server.The present invention is connected by target preparatory before receiving Media Stream acquisition instruction, once detecting that target connection is unavailable, then re-establish target connection, in this way when receiving Media Stream acquisition instruction, the target connection pre-established can be directly based upon, corresponding Media Stream rapidly is obtained from server, reduces the time needed for terminal obtains Media Stream.

Description

Media stream capturing method and device
Technical field
The present invention relates to network technique field more particularly to a kind of media stream capturing methods and device.
Background technique
With the development of network technology, more and more users' using terminal watches live video, live streaming view on network Frequency is generally based on RTMP (Real Time Messaging Protocol, real-time messages transport protocol) agreement, with Media Stream Form be supplied to terminal.
Currently, user can carry out clicking operation to some direct broadcast band (direct broadcasting room) at the terminal, when terminal detects When the operation, connection first is established with streaming media server, including successively shaken hands with streaming media server, establish network connection It is connected with stream is established, then sends play instruction to streaming media server, obtain Media Stream from streaming media server.
Above-mentioned technology just establishes connection with server after detecting user's operation, and the establishment of connection generally requires to consume Take the long period, causes the time needed for obtaining Media Stream longer.
Summary of the invention
The embodiment of the invention provides a kind of media stream capturing method and devices, can solve the relevant technologies and obtain Media Stream Longer problem of required time.The technical solution is as follows:
In a first aspect, providing a kind of media stream capturing method, comprising:
When starting live streaming in application, pre-establishing target connection, the target is connected for obtaining Media Stream from server, The live streaming application is for providing multiple direct broadcast bands;
Detect the state of the target connection;
When the state of target connection is down state, the target connection is re-established;
When receiving the Media Stream acquisition instruction to any direct broadcast band, connected based on the target, from the service Device obtains the Media Stream of the direct broadcast band.
It is described to pre-establish target connection in a kind of possible implementation, comprising:
Built in advance connecting object is distributed for built in advance connecting object pointer variable, initialize the built in advance connecting object first belongs to Property, the second attribute and third attribute value be first object value, the value of the 4th attribute is initial time, first attribute For describing whether to have been established TCP (Transmission Control Protocol, transmission control protocol) connection, described the Whether two attributes complete preposition instruction for describing, and the third attribute is for describing whether target connection can be used, and the described 4th Attribute is used to describe to finally receive the time of user's control message;
After success establishes TCP connection with the server, the value of first attribute is revised as the second target value;
After success carries out the interaction of multiple preposition instructions with the server, by second attribute and the third category The value of property is revised as second target value, and the value of the 4th attribute is updated to current time, the multiple preposition Instruction includes shake hands instruction, link order and creation stream instruction.
In a kind of possible implementation, the state of the detection target connection, comprising:
It attempts to read the user's control message that the server is sent;
When reading the user's control message that the server is sent, the value of the 4th attribute is updated to currently Time determines that the state of the target connection is available mode;
When the unread user's control message sent to the server, according to current time and the 4th attribute Time interval between value determines the state of the target connection.
In a kind of possible implementation, between the time according to current time between the value of the 4th attribute Every determining the state of target connection, comprising:
When time interval between current time and the value of the 4th attribute is greater than prefixed time interval, described in determination Target connection state be down state, the prefixed time interval be greater than the server send user's control message when Between be spaced;
When time interval between current time and the value of the 4th attribute is less than the prefixed time interval, suspend mode After first preset duration, by the step of executing the user's control message for attempting to read the server transmission, the mesh is determined Mark the state of connection, the corresponding time interval of first preset duration be less than the server send user's control message when Between be spaced.
In a kind of possible implementation, after the state of the detection target connection, the method also includes:
When the state of target connection is available mode, after the first preset duration of suspend mode, continues to execute trial and read The step of user's control message that the server is sent.
It is described when the state of target connection is down state in a kind of possible implementation, it re-establishes The target connection, comprising:
When the state of target connection is down state, after the second preset duration of suspend mode, closes the TCP and connect It connects, deletes the built in advance connecting object, the built in advance connecting object pointer variable is set for sky, re-executes and pre-establishes target The step of connection.
It is described when receiving the Media Stream acquisition instruction to any direct broadcast band in a kind of possible implementation, base It is connected in the target, the Media Stream of the direct broadcast band is obtained from the server, comprising:
When receiving the Media Stream acquisition instruction to any direct broadcast band, stream address and the stream of the direct broadcast band are obtained Title;
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is second target value When, it is connected based on the target, sends play instruction to the server, receive the Media Stream that the server is sent, it is described Play instruction carries the stream title and traffic identifier, and the traffic identifier is obtained from the response results of the creation stream instruction.
In a kind of possible implementation, after the stream address for obtaining the direct broadcast band and stream title, the side Method further include:
When the built in advance connecting object pointer variable is empty, it is based on the stream address, obtains media from the server Stream;Or,
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is the first object value When, it is based on the stream address, obtains Media Stream from the server.
Second aspect provides a kind of Media Stream acquisition device, comprising:
Module is established, in application, pre-establish target connection, target connection to be for from service when starting live streaming Device obtains Media Stream, and the live streaming application is for providing multiple direct broadcast bands;
Detection module, for detecting the state of the target connection;
It is described to establish module, it is also used to re-establish the mesh when the state that the target connects is down state Mark connection;
Module is obtained, for connecting based on the target when receiving the Media Stream acquisition instruction to any direct broadcast band It connects, the Media Stream of the direct broadcast band is obtained from the server.
In a kind of possible implementation, the module of establishing is used for:
Built in advance connecting object is distributed for built in advance connecting object pointer variable, initialize the built in advance connecting object first belongs to Property, the second attribute and third attribute value be first object value, the value of the 4th attribute is initial time, first attribute For describing that transmission control protocol TCP connection whether has been established, second attribute is for describing whether complete preposition instruction, institute Third attribute is stated for describing whether target connection can be used, the 4th attribute finally receives user's control message for describing Time;
After success establishes TCP connection with the server, the value of first attribute is revised as the second target value;
After success carries out the interaction of multiple preposition instructions with the server, by second attribute and the third category The value of property is revised as second target value, and the value of the 4th attribute is updated to current time, the multiple preposition Instruction includes shake hands instruction, link order and creation stream instruction.
In a kind of possible implementation, the detection module is used for:
It attempts to read the user's control message that the server is sent;
When reading the user's control message that the server is sent, the value of the 4th attribute is updated to currently Time determines that the state of the target connection is available mode;
When the unread user's control message sent to the server, according to current time and the 4th attribute Time interval between value determines the state of the target connection.
In a kind of possible implementation, the detection module is used for:
When time interval between current time and the value of the 4th attribute is greater than prefixed time interval, described in determination Target connection state be down state, the prefixed time interval be greater than the server send user's control message when Between be spaced;
When time interval between current time and the value of the 4th attribute is less than the prefixed time interval, suspend mode After first preset duration, by the step of executing the user's control message for attempting to read the server transmission, the mesh is determined Mark the state of connection, the corresponding time interval of first preset duration be less than the server send user's control message when Between be spaced.
In a kind of possible implementation, the detection module is also used to when the state of target connection be available mode When, after the first preset duration of suspend mode, continue to execute the step of attempting to read the user's control message that the server is sent.
In a kind of possible implementation, it is described establish module for when the target connection state be down state When, after the second preset duration of suspend mode, the TCP connection is closed, the built in advance connecting object is deleted, the built in advance connection pair is set As pointer variable be sky, re-execute pre-establish target connection the step of.
In a kind of possible implementation, the acquisition module is used for:
When receiving the Media Stream acquisition instruction to any direct broadcast band, stream address and the stream of the direct broadcast band are obtained Title;
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is second target value When, it is connected based on the target, sends play instruction to the server, receive the Media Stream that the server is sent, it is described Play instruction carries the stream title and traffic identifier, and the traffic identifier is obtained from the response results of the creation stream instruction.
In a kind of possible implementation, the acquisition module is also used to when the built in advance connecting object pointer variable be sky When, it is based on the stream address, obtains Media Stream from the server;Or,
The acquisition module is also used to when the built in advance connecting object pointer variable not be empty, and the third attribute takes When value is the first object value, it is based on the stream address, obtains Media Stream from the server.
The third aspect provides a kind of computer equipment, including processor and memory;The memory, for storing Computer program;The processor realizes that first aspect is any for executing the computer program stored on the memory Method and step described in kind implementation.
Fourth aspect provides a kind of computer readable storage medium, is stored in the computer readable storage medium Computer program realizes the step of method described in any implementation of first aspect when the computer program is executed by processor Suddenly.
Technical solution bring beneficial effect provided in an embodiment of the present invention includes at least:
It is connected by target preparatory before receiving Media Stream acquisition instruction, once detect that target connection is unavailable, Target connection is then re-established, in this way when receiving Media Stream acquisition instruction, the target pre-established can be directly based upon and connected It connects, rapidly obtains corresponding Media Stream from server, reduce the time needed for terminal obtains Media Stream.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodiment Attached drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other Attached drawing.
Fig. 1 is a kind of schematic diagram of the implementation environment of media stream capturing method provided in an embodiment of the present invention;
Fig. 2 is a kind of flow chart of media stream capturing method provided in an embodiment of the present invention;
Fig. 3 is a kind of flow chart of media stream capturing method provided in an embodiment of the present invention;
Fig. 4 is a kind of structural schematic diagram of Media Stream acquisition device provided in an embodiment of the present invention;
Fig. 5 is a kind of structural schematic diagram of terminal 500 provided in an embodiment of the present invention.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with attached drawing to embodiment party of the present invention Formula is described in further detail.
Fig. 1 is a kind of schematic diagram of the implementation environment of media stream capturing method provided in an embodiment of the present invention.Referring to Fig. 1, The implementation environment may include first terminal 101, server 102 and multiple second terminals 103.
First terminal 101 refers to the terminal that main broadcaster user is broadcast live, and second terminal 103 is to obtain Media Stream, for spectators The terminal of user's viewing live video.Server 102 is used to provide direct broadcast service for first terminal 101 and second terminal 103, has Body, the application that server 101 can be installed by first terminal 101 and second terminal 103 provides it service.The service Device 102 can be streaming media server, which can be the server cluster of multiple server compositions.
Main broadcaster user can carry out net cast, second terminal by first terminal 101 in direct broadcast band (direct broadcasting room) 103 spectators user can be with login service device 102, into the direct broadcast band of main broadcaster user.It is straight that video is carried out in main broadcaster user During broadcasting, the live video of main broadcaster user can be sent to server by first terminal 101 in real time in the form of Media Stream 102, the second terminal 103 in direct broadcast band is sent to by server 102, so that second terminal 103 is available to arrive Media Stream.
Fig. 2 is a kind of flow chart of media stream capturing method provided in an embodiment of the present invention.Referring to fig. 2, this method comprises:
201, when starting live streaming in application, pre-establishing target connection, target connection is for obtaining media from server Stream, the live streaming are applied for providing multiple direct broadcast bands.
202, the state of target connection is detected.
203, when the state of target connection is down state, target connection is re-established.
204, it when receiving the Media Stream acquisition instruction to any direct broadcast band, is connected based on the target, from the service Device obtains the Media Stream of the direct broadcast band.
Method provided in an embodiment of the present invention is connected, one by target preparatory before receiving Media Stream acquisition instruction Denier detects that target connection is unavailable, then re-establishes target connection, in this way when receiving Media Stream acquisition instruction, Ke Yizhi It connects based on the target connection pre-established, rapidly obtains corresponding Media Stream from server, reduce terminal and obtain Media Stream The required time.
In a kind of possible implementation, this pre-establishes target connection, comprising:
Built in advance connecting object is distributed for built in advance connecting object pointer variable, initialize the built in advance connecting object first belongs to Property, the second attribute and third attribute value be first object value, the value of the 4th attribute is initial time, which uses Transmission control protocol TCP connection whether has been established in description, second attribute is for describing whether complete preposition instruction, the third For attribute for describing whether target connection can be used, the 4th attribute is used to describe to finally receive the time of user's control message;
After success establishes TCP connection with the server, the value of first attribute is revised as the second target value;
After success carries out the interaction of multiple preposition instructions with the server, by taking for second attribute and the third attribute Value is revised as second target value, the value of the 4th attribute is updated to current time, multiple preposition instruction includes shaking hands Instruction, link order and creation stream instruction.
In a kind of possible implementation, the state of detection target connection, comprising:
It attempts to read the user's control message that the server is sent;
When reading the user's control message of server transmission, when the value of the 4th attribute is updated to current Between, determine that the state of target connection is available mode;
When the unread user's control message sent to the server, according to the value of current time and the 4th attribute Between time interval, determine the target connection state.
In a kind of possible implementation, this according to the time interval between current time and the value of the 4th attribute, Determine the state of target connection, comprising:
When time interval between current time and the value of the 4th attribute is greater than prefixed time interval, the target is determined The state of connection is down state, which is greater than the time interval that the server sends user's control message;
When time interval between current time and the value of the 4th attribute is less than the prefixed time interval, suspend mode first After preset duration, by the step of executing the user's control message for attempting to read server transmission, target connection is determined State, the corresponding time interval of the first preset duration are less than the time interval that the server sends user's control message.
In a kind of possible implementation, after the state of detection target connection, this method further include:
When the state of target connection is available mode, after the first preset duration of suspend mode, continuing to execute trial reading should The step of user's control message that server is sent.
In a kind of possible implementation, when the state for deserving target connection is down state, the mesh is re-established Mark connection, comprising:
When the state of target connection is down state, after the second preset duration of suspend mode, the TCP connection is closed, is deleted Except the built in advance connecting object, which is set for sky, re-executes the step for pre-establishing target connection Suddenly.
In a kind of possible implementation, when should receive the Media Stream acquisition instruction to any direct broadcast band, it is based on Target connection, the Media Stream of the direct broadcast band is obtained from the server, comprising:
When receiving the Media Stream acquisition instruction to any direct broadcast band, stream address and the stream name of the direct broadcast band are obtained Claim;
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is second target value, base It is connected in the target, sends play instruction to the server, receive the Media Stream of server transmission, which carries should Stream title and traffic identifier, the traffic identifier are obtained from the response results that the creation stream instructs.
In a kind of possible implementation, after the stream address of the acquisition direct broadcast band and stream title, this method is also wrapped It includes:
When the built in advance connecting object pointer variable is empty, it is based on the stream address, obtains Media Stream from the server;Or,
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is the first object value, base In the stream address, Media Stream is obtained from the server.
All the above alternatives can form alternative embodiment of the invention using any combination, herein no longer It repeats one by one.
Fig. 3 is a kind of flow chart of media stream capturing method provided in an embodiment of the present invention.This method can be held by terminal Row, which can be the second terminal 103 in implementation environment shown in Fig. 1, referring to Fig. 3, this method comprises:
301, when starting live streaming in application, terminal pre-establishes target connection, which is connected for obtaining from server Media Stream, the live streaming are applied for providing multiple direct broadcast bands.
Wherein, target connection can be RTMP stream connection, and direct broadcast band is also referred to as direct broadcasting room, and server can be stream matchmaker Body server.
In the embodiment of the present invention, user can carry out start-up operation to live streaming application at the terminal, such as click the live streaming and answer Icon triggers the enabled instruction applied to the live streaming.Terminal can star live streaming and answer when receiving the enabled instruction With, and establish target connection.In a kind of possible implementation, during starting live streaming application, terminal can be initialized Video player, the subsequent Media Stream got is played by the video player, and terminal can also initialize built in advance connection Management module executes the process for pre-establishing target connection by the built in advance connection management module.
Certainly, the embodiment of the present invention is illustrated for only establishing target connection when terminal is in starting live streaming application, real On border, terminal can also click any one direct broadcast band in user, be built with other opportunitys before triggering Media Stream acquisition instruction Vertical target connection, it is not limited in the embodiment of the present invention.
In a kind of possible implementation, before terminal pre-establishes target connection, step 3011 can be executed:
Step 3011, terminal initialization built in advance connecting object pointer variable are sky, obtain domain name.
Wherein, which can be expressed as " PSLinkObjectPtr ", when it is empty " NULL " When, indicate that the pointer variable is not directed toward any object.
In a kind of possible implementation, terminal can send domain name acquisition request to stream media scheduling management server, The domain name of stream media server system, the domain name and terminal are returned from stream media scheduling management server to terminal is obtaining media The IP address for the server that may be accessed when stream is corresponding.
In a kind of possible implementation, terminal can initialize built in advance and connect when initializing built in advance connection management module Pointer to object variable is connect, domain name is obtained, starts a built in advance connection management thread, is responsible for pre-establishing target company by the thread It connects.In a kind of possible implementation, target establishment of connection process may include step 3012 to step 3017:
Step 3012, when built in advance connecting object pointer variable is empty, terminal is that built in advance connecting object pointer variable is distributed Built in advance connecting object, the value for initializing the first attribute of built in advance connecting object, the second attribute and third attribute is first object Value, the value of the 4th attribute are initial time, execute step 3013.
Wherein, for first attribute for describing whether TCP connection has been established, which can use variable " IsTCPAvailable " is indicated;For second attribute for describing whether complete preposition instruction, which can use variable " IsPreCommandFinished " is indicated;For the third attribute for describing whether target connection can be used, which can be with It is indicated with variable " IsALive ", the 4th attribute is used to describe to finally receive the time of user's control message, the 4th attribute It can be indicated with variable " LastRPingTime ".
First attribute, the second attribute and third attribute can there are two value, such as first object value and the second target value, First object value and the second target value may each be logical value, for example, first object value can be False, the second target value can To be True.The value of 4th attribute is the time, and initial time can be 0.
When the value of the first attribute is first object value, expression does not set up TCP connection, when the value of the first attribute is the When two target values, TCP connection is had been established in expression;When the value of the second attribute is first object value, expression does not complete preposition finger It enables, when the value of the second attribute is the second target value, preposition instruction is completed in expression;When the value of third attribute is the first mesh It when scale value, indicates that target connection is unavailable, when the value of third attribute is the second target value, indicates that target connection is available.
Terminal is after the built in advance connecting object pointer variable distributes built in advance connecting object, and built in advance connecting object pointer variable is then It is not sky.
Step 3013, when the value of first attribute is first object value, terminal and server establish TCP connection, such as Fruit fails, and after the second preset duration of suspend mode, deletes the built in advance connecting object, setting built in advance connecting object pointer variable is sky, weight It is new to execute step 3012;If it is successful, the value of first attribute is revised as the second target value, step 3014 is executed.
Domain name, in the step 3013, the corresponding IP of the available domain name of terminal are obtained for terminal in step 3011 (Internet Protocol, Internet protocol) address, server corresponding with the IP address establish TCP connection.For example, eventually End can be translated domain names by DNS (Domain Name System, domain name system) server as corresponding IP address, example Such as, terminal can send domain name analysis request to dns server, and domain name mapping request carries the domain got in step 3011 Name, returns to the corresponding IP address of the domain name by dns server.
Step 3014, when the value of second attribute is first object value, terminal and server carry out multiple preposition fingers The interaction of order after the second preset duration of suspend mode, closes the TCP connection if any instruction fails, and deletes built in advance connection pair As setting built in advance connecting object pointer variable is sky;If it is successful, the value of second attribute and third attribute is revised as The value of 4th attribute is updated to current time by two target values.
Wherein, it is preposition instruction refer to broadcastings (Play) instruction before instruction, it is multiple it is preposition instruction including shake hands instruction, Connect (Connect) instruction and creation stream (CreateStream) instruction.
The interaction that terminal and server carry out multiple preposition instructions includes: that terminal to server initiates RTMP handshake procedure, It shakes hands and sends Connect instruction to server after completing, and wait its response results, then initiated to server CreateStream instruction, and wait its response results.Handshake procedure is for differentiating that terminal and server whether there is; Network connection is set up after Connect is instructed successfully, between terminal and server, but can not also support media flow transmission; It, can be with media stream between terminal and server after CreateStream is instructed successfully.
In a kind of possible implementation, after success carries out the interaction of multiple preposition instructions with the server, terminal can To obtain traffic identifier from the response results that the creation stream instructs, traffic identifier that is to say stream ID (identification, identity mark Know).
Terminal has received the response results of server during carrying out preposition instruction interaction with server, even if The response results are not user's control messages, but still can determine the company between terminal and server by the response results It connects and is available, therefore terminal can once update the value of the 4th attribute.
For server, server receive terminal initiation TCP connection, RTMP shakes hands, Connect is instructed and After CreateStream instruction, respective handling can be carried out.For example, the reception and processing step of instruction can be by the masters of server Process executes.
After terminal pre-establishes target connection, since user not yet clicks any direct broadcast band, terminal needs to maintain The heartbeat of the target connection pre-established, detailed process is referring to subsequent step 302 to step 303.
302, terminal detects the state of target connection, which includes available mode and down state.
Wherein, available mode indicates that terminal can obtain Media Stream from server, no based on the target connection pre-established Available mode indicates that terminal cannot obtain Media Stream from server based on the target connection pre-established.
In the embodiment of the present invention, terminal can carry out information exchange between server, to detect the state of target connection, In a kind of possible implementation, which can be the interaction of user's control message, and correspondingly, which can be with Include the following steps 3021 to step 3023:
Step 3021, terminal are attempted to read the user's control message that the server is sent, and send when reading the server User's control message when, the value of the 4th attribute is updated to current time, determine the target connection state be available State executes step 3022;When the unread user's control message sent to the server, step 3023 is executed.
In the embodiment of the present invention, terminal can carry out user's control message interaction between server, by interaction scenario, To determine the state of target connection.For example, terminal can attempt to read the Ping user's control message from server, if read Ping user's message is got, then to server response Pong user's control message.Since terminal receives the control from server Message processed shows that the target pre-established is connected as available mode, and therefore, terminal can carry out more the value of the 4th attribute Newly.
Correspondingly, server can cross certain time interval with every, based on the target connection pre-established, send to server Ping user's control message, and the Pong user's control message for waiting terminal to respond.For example, sending the step of control message to terminal Suddenly it can be executed by the host process of server.
It should be noted that the embodiment of the present invention is come with carrying out user's control message interaction between terminal and server Determine target connection state for be illustrated, in fact, between terminal and server can also use other interactive modes, Such as the interaction of heartbeat message, to determine the state of target connection, it is not limited in the embodiment of the present invention.
Step 3022, when the state of target connection is available mode, after the first preset duration of terminal sleeping, continue to hold Row attempts the step of reading the user's control message that the server is sent.
Wherein, which was less than between the time that the server sends user's control message Every for example, the time interval that server sends user's control message is 5 seconds, the first preset duration is 1 second.
In the embodiment of the present invention, when terminal detects target connection in available mode, when terminal can be with one section of suspend mode Between after, reattempt read the user's control message from server, wherein the time of suspend mode be less than server send user's control The time interval of message, this sleep mode can save terminal under the premise of not influencing to detect the state of target connection Resource consumption.
Step 3023, terminal obtain current time, judge between the time between current time and the value of the 4th attribute Every whether being greater than prefixed time interval, if so, determining that the state of target connection is down state, if not, suspend mode the After one preset duration, by the step of executing the user's control message for attempting to read server transmission, determine that the target connects State.
Wherein, which is greater than the time interval that the server sends user's control message, for example, server The time interval for sending user's control message is 5 seconds, and prefixed time interval can be 8 seconds.
If the time interval between current time and the value of the 4th attribute is greater than prefixed time interval, show in advance There are risk, target connection is unavailable for the target connection of foundation.If time interval is less than prefixed time interval, suspend mode one After the section time, continue state-detection.
It should be noted that the step 3023 is according between the time between current time and the value of the 4th attribute Every, determine the target connection state a kind of possible implementation.By being controlled according to current time with user is finally received Difference between the time of message processed can accurately learn whether normally carrying out user's control between terminal and server The interaction of message, so that it is determined that the state of target connection.
303, when the state of target connection is down state, terminal re-establishes target connection.
In a kind of possible implementation, it includes: the shape when target connection that terminal, which re-establishes the process that target connects, When state is down state, after the second preset duration of suspend mode, the connection of built in advance pointed by built in advance connecting object pointer variable is closed The TCP connection of object, and built in advance connecting object pointed by built in advance connecting object pointer variable is deleted, built in advance connection pair is set As pointer variable be sky, re-execute pre-establish target connection the step of, that is to say, re-execute the steps 3012 to step 3014.Wherein, compared to the first preset duration, the second preset duration be can be set shorter, and such as 10 milliseconds.
Reliable target can be kept to connect by step 302 to step 303, between terminal and server, to guarantee For user when clicking direct broadcast band, terminal directly can obtain Media Stream from server using target connection.
304, when receiving the Media Stream acquisition instruction to any direct broadcast band, terminal is connected based on the target, from this Server obtains the Media Stream of the direct broadcast band.
In the embodiment of the present invention, terminal can show multiple live streamings frequency that live streaming application provides after starting live streaming application Road, user can carry out clicking operation to any one direct broadcast band, trigger the Media Stream acquisition instruction to the direct broadcast band, After terminal receives the Media Stream acquisition instruction, it can be broadcast to the Media Stream of the server request direct broadcast band It puts.
In a kind of possible implementation, is connected based on the target, the Media Stream of the direct broadcast band is obtained from the server Include the following steps 3041 to step 3046:
Step 3041, when receiving the Media Stream acquisition instruction to any direct broadcast band, terminal obtains the direct broadcast band Stream address and stream title.
In the embodiment of the present invention, live streaming application provide all direct broadcast bands be corresponding with stream address and stream title, when with When any one direct broadcast band is clicked at family, terminal can be obtained according to the corresponding relationship between direct broadcast band and stream address and stream title Get stream address (StreamURL) and stream title (StreamName) of the direct broadcast band that user is clicked.
In a kind of possible implementation, stream media scheduling management server can store the mark and stream of direct broadcast band Corresponding relationship between address and stream title, when terminal detects that user clicks the operation of any one direct broadcast band, terminal can It is requested with being sent to stream media scheduling management server, which carries the mark for the direct broadcast band that user is clicked, Streaming Media Management and running server can according to terminal send direct broadcast band mark, inquire corresponding relationship, by corresponding stream address with Stream title is sent to terminal, so that terminal gets stream address and the stream title of direct broadcast band.
Step 3042, terminal judge whether the value of built in advance connecting object pointer variable is empty, if so, executing step 3044, if not, executing step 3043.
Terminal can first judge whether the value of built in advance connecting object pointer variable is sky, if it is sky, shows to build in advance Vertical target connection is unavailable, then terminal can execute step 3043, if being not sky, terminal, which can execute, reads third category The step of property.
Step 3043, terminal judge the third attribute of built in advance connecting object pointed by built in advance connecting object pointer variable Whether value is first object value, if so, step 3044 is executed, if not, executing step 3045.
When the value of third attribute is first object value, indicate that target connection is available, when the value of third attribute is not When first object value, indicate that target connection is unavailable.
Step 3044, terminal are based on the stream address, obtain Media Stream from the server.
In the embodiment of the present invention, when the built in advance connecting object pointer variable is empty, terminal executes the step 3044, or, When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is the first object value, terminal executes should Step 3044.
The step 3044 is that terminal is based on stream address, executes normal Media Stream and obtains process, the acquisition process of Media Stream It may include: after terminal establishes TCP connection and carry out preposition instruction interaction with server, based on stream address, to be sent to server Play instruction (Play instruction) receives the Media Stream that server returns.
Step 3045, terminal are connected based on the target, send play instruction to the server, which carries the stream Mark and stream title.
Wherein, which obtains from the response results that the creation stream instructs in step 3015.
In the embodiment of the present invention, when the built in advance connecting object pointer variable be not it is empty, and the value of the third attribute be should When the second target value, terminal executes the step 3045.After terminal pre-establishes target connection, there is biography between terminal and server The channel of defeated Media Stream, therefore, terminal can send Play instruction, to server when needing to obtain Media Stream to request to take Business device starts to send Media Stream to terminal.Wherein, the stream title that carries is used to identify that needs to obtain is which road in Play instruction Media Stream, the corresponding stream title of every road Media Stream, server can be according to the stream titles carried in Play instruction, to terminal Transmit the corresponding Media Stream of stream title.Which stream is the video frame that the traffic identifier carried in Play instruction is used to distinguish transmission belong to The corresponding Media Stream of title, the traffic identifier can be also used for server distinguish different media flows core buffer (including send With reception buffer area) and the relevant informations such as associated object and some attributes, to ensure the correct transmission of Media Stream.
In a kind of possible implementation, when the value of the third attribute be second target value when, terminal can first by Built in advance connecting object pointer variable is assigned to connecting object pointer variable, and sets empty for built in advance connecting object pointer variable Afterwards, then with traffic identifier and entitled parameter is flowed, is connected based on target, send Play instruction to server, and wait Media Stream.
Step 3046, terminal receive the Media Stream of server transmission.
After terminal to server sends Play instruction, server can be parsed out the traffic identifier that Play instruction carries and stream name Claim, and then server may determine that the corresponding Media Stream of stream title whether there is, if it is present forwarding the media to terminal Stream if it does not exist, then after superior server requests the Media Stream, then to terminal is transmitted to the Media Stream.
Wherein, reception Play is instructed, is parsed traffic identifier and flow title and can be executed by the host process of server, into And the target pre-established can be connected and be transferred to the subprocess of server by the host process, when transfer as far as possible to target into Journey transfer, which, which refers to, pulls the subprocess to the corresponding Media Stream of stream title from parent server, when So, it if there is no the target subprocess, that is to say, none of subprocess is pulled from parent server to the stream The corresponding Media Stream of title, then the host process can choose the smallest subprocess of load, and to the smallest son of the load into The target connection that journey transfer pre-establishes.Then, the subprocess for being transferred target connection may determine that the stream title is corresponding Media Stream whether there is, and the Media Stream be forwarded if it is present connecting based on the target to terminal, if it does not exist, then upwards After grade server requests the Media Stream, then based on target connection, it is transmitted to the Media Stream to terminal, so that terminal can receive To Media Stream.
Terminal is after obtaining Media Stream, and further, terminal can be decoded to Media Stream and rendering processing, display view The first frame of frequency.By shifting to an earlier date the movement for establishing connection, before user watches video, target connection is pre-established, use is being received It after the instruction of certain direct broadcast band is watched at family, is directly connected using the target pre-established, sends Play instruction to server immediately, The Media Stream of server transmission can be quickly received, to reduce video head screen duration, reduces user and watches video head frame Waiting time.Wherein, first screen duration is from Media Stream acquisition instruction that user triggers is received to showing video head frame This period corresponding duration.
Optionally, when closing live streaming in application, terminal can destroy target connection.For example, user can at the terminal into Row closes the operation of live streaming application, triggers the out code applied to the live streaming, and when receiving the out code, terminal can be with The live streaming application is closed, target connection is destroyed.In a kind of possible implementation, during closing live streaming application, terminal Video player can be destroyed, built in advance connection management module is destroyed, stops built in advance connection management thread, closes built in advance connecting object The network connection of built in advance connecting object indicated by pointer variable, and delete built in advance connecting object.
Method provided in an embodiment of the present invention is connected, one by target preparatory before receiving Media Stream acquisition instruction Denier detects that target connection is unavailable, then re-establishes target connection, in this way when receiving Media Stream acquisition instruction, Ke Yizhi It connects based on the target connection pre-established, rapidly obtains corresponding Media Stream from server, reduce terminal and obtain Media Stream The required time.
Fig. 4 is a kind of structural schematic diagram of Media Stream acquisition device provided in an embodiment of the present invention.Referring to Fig. 4, the device Include:
Establish module 401, for when starting live streaming in application, pre-establishing target connection, target connection is for from clothes Business device obtains Media Stream, which applies for providing multiple direct broadcast bands;
Detection module 402, for detecting the state of target connection;
This establishes module 401, is also used to re-establish target company when the state that the target connects is down state It connects;
Module 403 is obtained, for connecting based on the target when receiving the Media Stream acquisition instruction to any direct broadcast band It connects, the Media Stream of the direct broadcast band is obtained from the server.
In a kind of possible implementation, this is established module 401 and is used for:
Built in advance connecting object is distributed for built in advance connecting object pointer variable, initialize the built in advance connecting object first belongs to Property, the second attribute and third attribute value be first object value, the value of the 4th attribute is initial time, which uses Transmission control protocol TCP connection whether has been established in description, second attribute is for describing whether complete preposition instruction, the third For attribute for describing whether target connection can be used, the 4th attribute is used to describe to finally receive the time of user's control message;
After success establishes TCP connection with the server, the value of first attribute is revised as the second target value;
After success carries out the interaction of multiple preposition instructions with the server, by taking for second attribute and the third attribute Value is revised as second target value, the value of the 4th attribute is updated to current time, multiple preposition instruction includes shaking hands Instruction, link order and creation stream instruction.
In a kind of possible implementation, which is used for:
It attempts to read the user's control message that the server is sent;
When reading the user's control message of server transmission, when the value of the 4th attribute is updated to current Between, determine that the state of target connection is available mode;
When the unread user's control message sent to the server, according to the value of current time and the 4th attribute Between time interval, determine the target connection state.
In a kind of possible implementation, which is used for:
When time interval between current time and the value of the 4th attribute is greater than prefixed time interval, the target is determined The state of connection is down state, which is greater than the time interval that the server sends user's control message;
When time interval between current time and the value of the 4th attribute is less than the prefixed time interval, suspend mode first After preset duration, by the step of executing the user's control message for attempting to read server transmission, target connection is determined State, the corresponding time interval of the first preset duration are less than the time interval that the server sends user's control message.
In a kind of possible implementation, which is also used to when the state of target connection be available mode When, after the first preset duration of suspend mode, continue to execute the step of attempting to read the user's control message that the server is sent.
In a kind of possible implementation, this establish module 401 for when the target connection state be down state When, after the second preset duration of suspend mode, the TCP connection is closed, the built in advance connecting object is deleted, which is set Variable is sky, re-executes the step of pre-establishing target connection.
In a kind of possible implementation, which is used for:
When receiving the Media Stream acquisition instruction to any direct broadcast band, stream address and the stream name of the direct broadcast band are obtained Claim;
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is second target value, base It is connected in the target, sends play instruction to the server, receive the Media Stream of server transmission, which carries should Stream title and traffic identifier, the traffic identifier are obtained from the response results that the creation stream instructs.
In a kind of possible implementation, which is also used to when the built in advance connecting object pointer variable be sky When, it is based on the stream address, obtains Media Stream from the server;Or,
The acquisition module 403 is also used to when the built in advance connecting object pointer variable not be empty, and the value of the third attribute When for the first object value, it is based on the stream address, obtains Media Stream from the server.
In the embodiment of the present invention, connected by target preparatory before receiving Media Stream acquisition instruction, once it detects Target connection is unavailable, then re-establishes target connection, in this way when receiving Media Stream acquisition instruction, can be directly based upon pre- The target connection first established, rapidly obtains corresponding Media Stream from server, when reducing needed for terminal acquisition Media Stream Between.
It should be understood that Media Stream acquisition device provided by the above embodiment is when obtaining Media Stream, only with above-mentioned each The division progress of functional module can according to need and for example, in practical application by above-mentioned function distribution by different function Energy module is completed, i.e., the internal structure of equipment is divided into different functional modules, to complete whole described above or portion Divide function.In addition, Media Stream acquisition device provided by the above embodiment and media stream capturing method embodiment belong to same design, Its specific implementation process is detailed in embodiment of the method, and which is not described herein again.
Fig. 5 is a kind of structural schematic diagram of terminal 500 provided in an embodiment of the present invention.The terminal 500 may is that intelligent hand (Moving Picture Experts Group Audio Layer III, dynamic image are special for machine, tablet computer, MP3 player Family's compression standard audio level 3), MP4 (Moving Picture Experts Group Audio Layer IV, dynamic image Expert's compression standard audio level 4) player, laptop or desktop computer.Terminal 500 is also possible to referred to as user and sets Other titles such as standby, portable terminal, laptop terminal, terminal console.
In general, terminal 500 includes: processor 501 and memory 502.
Processor 501 may include one or more processing cores, such as 4 core processors, 8 core processors etc..Place Reason device 501 can use DSP (Digital Signal Processing, Digital Signal Processing), FPGA (Field- Programmable Gate Array, field programmable gate array), PLA (Programmable Logic Array, may be programmed Logic array) at least one of example, in hardware realize.Processor 501 also may include primary processor and coprocessor, master Processor is the processor for being handled data in the awake state, also referred to as CPU (Central Processing Unit, central processing unit);Coprocessor is the low power processor for being handled data in the standby state.? In some embodiments, processor 501 can be integrated with GPU (Graphics Processing Unit, image processor), GPU is used to be responsible for the rendering and drafting of content to be shown needed for display screen.In some embodiments, processor 501 can also be wrapped AI (Artificial Intelligence, artificial intelligence) processor is included, the AI processor is for handling related machine learning Calculating operation.
Memory 502 may include one or more computer readable storage mediums, which can To be non-transient.Memory 502 may also include high-speed random access memory and nonvolatile memory, such as one Or multiple disk storage equipments, flash memory device.In some embodiments, the non-transient computer in memory 502 can Storage medium is read for storing at least one instruction, at least one instruction performed by processor 501 for realizing this Shen Please in embodiment of the method provide media stream capturing method.
In some embodiments, terminal 500 is also optional includes: peripheral device interface 503 and at least one peripheral equipment. It can be connected by bus or signal wire between processor 501, memory 502 and peripheral device interface 503.Each peripheral equipment It can be connected by bus, signal wire or circuit board with peripheral device interface 503.Specifically, peripheral equipment includes: radio circuit 504, at least one of display screen 505, camera 506, voicefrequency circuit 507, positioning component 508 and power supply 509.
Peripheral device interface 503 can be used for I/O (Input/Output, input/output) is relevant outside at least one Peripheral equipment is connected to processor 501 and memory 502.In some embodiments, processor 501, memory 502 and peripheral equipment Interface 503 is integrated on same chip or circuit board;In some other embodiments, processor 501, memory 502 and outer Any one or two in peripheral equipment interface 503 can realize on individual chip or circuit board, the present embodiment to this not It is limited.
Radio circuit 504 is for receiving and emitting RF (Radio Frequency, radio frequency) signal, also referred to as electromagnetic signal.It penetrates Frequency circuit 504 is communicated by electromagnetic signal with communication network and other communication equipments.Radio circuit 504 turns electric signal It is changed to electromagnetic signal to be sent, alternatively, the electromagnetic signal received is converted to electric signal.Optionally, radio circuit 504 wraps It includes: antenna system, RF transceiver, one or more amplifiers, tuner, oscillator, digital signal processor, codec chip Group, user identity module card etc..Radio circuit 504 can be carried out by least one wireless communication protocol with other terminals Communication.The wireless communication protocol includes but is not limited to: Metropolitan Area Network (MAN), each third generation mobile communication network (2G, 3G, 4G and 5G), wireless office Domain net and/or WiFi (Wireless Fidelity, Wireless Fidelity) network.In some embodiments, radio circuit 504 may be used also To include the related circuit of NFC (Near Field Communication, wireless near field communication), the application is not subject to this It limits.
Display screen 505 is for showing UI (UserInterface, user interface).The UI may include figure, text, figure Mark, video and its their any combination.When display screen 505 is touch display screen, display screen 505 also there is acquisition to show The ability of the touch signal on the surface or surface of screen 505.The touch signal can be used as control signal and be input to processor 501 are handled.At this point, display screen 505 can be also used for providing virtual push button and/or dummy keyboard, also referred to as soft button and/or Soft keyboard.In some embodiments, display screen 505 can be one, and the front panel of terminal 500 is arranged;In other embodiments In, display screen 505 can be at least two, be separately positioned on the different surfaces of terminal 500 or in foldover design;In still other reality It applies in example, display screen 505 can be flexible display screen, be arranged on the curved surface of terminal 500 or on fold plane.Even, it shows Display screen 505 can also be arranged to non-rectangle irregular figure, namely abnormity screen.Display screen 505 can use LCD (Liquid Crystal Display, liquid crystal display), OLED (Organic Light-Emitting Diode, Organic Light Emitting Diode) Etc. materials preparation.
CCD camera assembly 506 is for acquiring image or video.Optionally, CCD camera assembly 506 include front camera and Rear camera.In general, the front panel of terminal is arranged in front camera, the back side of terminal is arranged in rear camera.One In a little embodiments, rear camera at least two is main camera, depth of field camera, wide-angle camera, focal length camera shooting respectively Any one in head, to realize that main camera and the fusion of depth of field camera realize background blurring function, main camera and wide-angle Camera fusion realizes that pan-shot and VR (Virtual Reality, virtual reality) shooting function or other fusions are clapped Camera shooting function.In some embodiments, CCD camera assembly 506 can also include flash lamp.Flash lamp can be monochromatic warm flash lamp, It is also possible to double-colored temperature flash lamp.Double-colored temperature flash lamp refers to the combination of warm light flash lamp and cold light flash lamp, can be used for not With the light compensation under colour temperature.
Voicefrequency circuit 507 may include microphone and loudspeaker.Microphone is used to acquire the sound wave of user and environment, and will Sound wave, which is converted to electric signal and is input to processor 501, to be handled, or is input to radio circuit 504 to realize voice communication. For stereo acquisition or the purpose of noise reduction, microphone can be separately positioned on the different parts of terminal 500 to be multiple.Mike Wind can also be array microphone or omnidirectional's acquisition type microphone.Loudspeaker is then used to that processor 501 or radio circuit will to be come from 504 electric signal is converted to sound wave.Loudspeaker can be traditional wafer speaker, be also possible to piezoelectric ceramic loudspeaker.When When loudspeaker is piezoelectric ceramic loudspeaker, the audible sound wave of the mankind can be not only converted electrical signals to, it can also be by telecommunications Number the sound wave that the mankind do not hear is converted to carry out the purposes such as ranging.In some embodiments, voicefrequency circuit 507 can also include Earphone jack.
Positioning component 508 is used for the current geographic position of positioning terminal 500, to realize navigation or LBS (Location Based Service, location based service).Positioning component 508 can be the GPS (Global based on the U.S. Positioning System, global positioning system), the dipper system of China, Russia Gray receive this system or European Union The positioning component of Galileo system.
Power supply 509 is used to be powered for the various components in terminal 500.Power supply 509 can be alternating current, direct current, Disposable battery or rechargeable battery.When power supply 509 includes rechargeable battery, which can support wired charging Or wireless charging.The rechargeable battery can be also used for supporting fast charge technology.
In some embodiments, terminal 500 further includes having one or more sensors 510.The one or more sensors 510 include but is not limited to: acceleration transducer 511, gyro sensor 512, pressure sensor 513, fingerprint sensor 514, Optical sensor 515 and proximity sensor 516.
The acceleration that acceleration transducer 511 can detecte in three reference axis of the coordinate system established with terminal 500 is big It is small.For example, acceleration transducer 511 can be used for detecting component of the acceleration of gravity in three reference axis.Processor 501 can With the acceleration of gravity signal acquired according to acceleration transducer 511, touch display screen 505 is controlled with transverse views or longitudinal view Figure carries out the display of user interface.Acceleration transducer 511 can be also used for the acquisition of game or the exercise data of user.
Gyro sensor 512 can detecte body direction and the rotational angle of terminal 500, and gyro sensor 512 can To cooperate with acquisition user to act the 3D of terminal 500 with acceleration transducer 511.Processor 501 is according to gyro sensor 512 Following function may be implemented in the data of acquisition: when action induction (for example changing UI according to the tilt operation of user), shooting Image stabilization, game control and inertial navigation.
The lower layer of side frame and/or touch display screen 505 in terminal 500 can be set in pressure sensor 513.Work as pressure When the side frame of terminal 500 is arranged in sensor 513, user can detecte to the gripping signal of terminal 500, by processor 501 Right-hand man's identification or prompt operation are carried out according to the gripping signal that pressure sensor 513 acquires.When the setting of pressure sensor 513 exists When the lower layer of touch display screen 505, the pressure operation of touch display screen 505 is realized to UI circle according to user by processor 501 Operability control on face is controlled.Operability control includes button control, scroll bar control, icon control, menu At least one of control.
Fingerprint sensor 514 is used to acquire the fingerprint of user, collected according to fingerprint sensor 514 by processor 501 The identity of fingerprint recognition user, alternatively, by fingerprint sensor 514 according to the identity of collected fingerprint recognition user.It is identifying When the identity of user is trusted identity out, the user is authorized to execute relevant sensitive operation, the sensitive operation packet by processor 501 Include solution lock screen, check encryption information, downloading software, payment and change setting etc..Terminal can be set in fingerprint sensor 514 500 front, the back side or side.When being provided with physical button or manufacturer Logo in terminal 500, fingerprint sensor 514 can be with It is integrated with physical button or manufacturer Logo.
Optical sensor 515 is for acquiring ambient light intensity.In one embodiment, processor 501 can be according to optics The ambient light intensity that sensor 515 acquires controls the display brightness of touch display screen 505.Specifically, when ambient light intensity is higher When, the display brightness of touch display screen 505 is turned up;When ambient light intensity is lower, the display for turning down touch display screen 505 is bright Degree.In another embodiment, the ambient light intensity that processor 501 can also be acquired according to optical sensor 515, dynamic adjust The acquisition parameters of CCD camera assembly 506.
Proximity sensor 516, also referred to as range sensor are generally arranged at the front panel of terminal 500.Proximity sensor 516 For acquiring the distance between the front of user Yu terminal 500.In one embodiment, when proximity sensor 516 detects use When family and the distance between the front of terminal 500 gradually become smaller, touch display screen 505 is controlled from bright screen state by processor 501 It is switched to breath screen state;When proximity sensor 516 detects user and the distance between the front of terminal 500 becomes larger, Touch display screen 505 is controlled by processor 501 and is switched to bright screen state from breath screen state.
It will be understood by those skilled in the art that the restriction of the not structure paired terminal 500 of structure shown in Fig. 5, can wrap It includes than illustrating more or fewer components, perhaps combine certain components or is arranged using different components.
In the exemplary embodiment, a kind of computer readable storage medium for being stored with computer program, example are additionally provided It is such as stored with the memory of computer program, above-mentioned computer program realizes the media in above-described embodiment when being executed by processor Flow acquisition methods.For example, the computer readable storage medium can be read-only memory (Read-Only Memory, ROM), with Machine accesses memory (Random Access Memory, RAM), CD-ROM (Compact Disc Read-Only Memory, CD-ROM), tape, floppy disk and optical data storage devices etc..
Those of ordinary skill in the art will appreciate that realizing that all or part of the steps of above-described embodiment can pass through hardware It completes, relevant hardware can also be instructed to complete by program, the program can store in a kind of computer-readable In storage medium, storage medium mentioned above can be read-only memory, disk or CD etc..
The foregoing is merely presently preferred embodiments of the present invention, is not intended to limit the invention, it is all in spirit of the invention and Within principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.

Claims (18)

1. a kind of media stream capturing method, which is characterized in that the described method includes:
When starting live streaming in application, pre-establishing target connection, the target connection is described for obtaining Media Stream from server Live streaming application is for providing multiple direct broadcast bands;
Detect the state of the target connection;
When the state of target connection is down state, the target connection is re-established;
When receiving the Media Stream acquisition instruction to any direct broadcast band, is connected based on the target, obtained from the server Take the Media Stream of the direct broadcast band.
2. the method according to claim 1, wherein described pre-establish target connection, comprising:
For built in advance connecting object pointer variable distribute built in advance connecting object, initialize the built in advance connecting object the first attribute, The value of second attribute and third attribute is first object value, and the value of the 4th attribute is initial time, and first attribute is used Transmission control protocol TCP connection whether has been established in description, second attribute is described for describing whether complete preposition instruction Third attribute is for describing whether target connection can be used, and the 4th attribute is for describing to finally receive user's control message Time;
After success establishes TCP connection with the server, the value of first attribute is revised as the second target value;
After success carries out the interaction of multiple preposition instructions with the server, by second attribute and the third attribute Value is revised as second target value, and the value of the 4th attribute is updated to current time, the multiple preposition instruction Including instruction of shaking hands, link order and creation stream instruction.
3. according to the method described in claim 2, it is characterized in that, the state of the detection target connection, comprising:
It attempts to read the user's control message that the server is sent;
When reading the user's control message that the server is sent, when the value of the 4th attribute is updated to current Between, determine that the state of the target connection is available mode;
When the unread user's control message sent to the server, according to the value of current time and the 4th attribute Between time interval, determine the state of target connection.
4. according to the method described in claim 3, it is characterized in that, the value according to current time and the 4th attribute Between time interval, determine the state of target connection, comprising:
When time interval between current time and the value of the 4th attribute is greater than prefixed time interval, the target is determined The state of connection is down state, and the prefixed time interval was greater than between the time that the server sends user's control message Every;
When time interval between current time and the value of the 4th attribute is less than the prefixed time interval, suspend mode first After preset duration, by the step of executing the user's control message for attempting to read the server transmission, determine that the target connects The state connect, the corresponding time interval of first preset duration were less than between the time that the server sends user's control message Every.
5. described according to the method described in claim 4, it is characterized in that, after the state of detection target connection Method further include:
When the state of target connection is available mode, after the first preset duration of suspend mode, continue to execute described in trial reading The step of user's control message that server is sent.
6. according to the method described in claim 2, it is characterized in that, described when the state of target connection is down state When, re-establish the target connection, comprising:
When the state of target connection is down state, after the second preset duration of suspend mode, the TCP connection is closed, is deleted Except the built in advance connecting object, the built in advance connecting object pointer variable is set for sky, re-executes and pre-establishes target connection The step of.
7. according to the method described in claim 2, it is characterized in that, described ought receive obtains the Media Stream of any direct broadcast band When instruction fetch, is connected based on the target, the Media Stream of the direct broadcast band is obtained from the server, comprising:
When receiving the Media Stream acquisition instruction to any direct broadcast band, stream address and the stream name of the direct broadcast band are obtained Claim;
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is second target value, It is connected based on the target, sends play instruction to the server, receive the Media Stream that the server is sent, the broadcasting Instruction carries the stream title and traffic identifier, and the traffic identifier is obtained from the response results of the creation stream instruction.
8. the method according to the description of claim 7 is characterized in that the stream address for obtaining the direct broadcast band and stream title Later, the method also includes:
When the built in advance connecting object pointer variable is empty, it is based on the stream address, obtains Media Stream from the server; Or,
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is the first object value, Based on the stream address, Media Stream is obtained from the server.
9. a kind of Media Stream acquisition device, which is characterized in that described device includes:
Module is established, for, in application, pre-establishing target connection, the target connection from server for obtain when starting live streaming Media Stream is taken, the live streaming application is for providing multiple direct broadcast bands;
Detection module, for detecting the state of the target connection;
It is described to establish module, it is also used to re-establish the target when the state that the target connects is down state and connect It connects;
Module is obtained, for being connected based on the target when receiving the Media Stream acquisition instruction to any direct broadcast band, from The server obtains the Media Stream of the direct broadcast band.
10. device according to claim 9, which is characterized in that the module of establishing is used for:
For built in advance connecting object pointer variable distribute built in advance connecting object, initialize the built in advance connecting object the first attribute, The value of second attribute and third attribute is first object value, and the value of the 4th attribute is initial time, and first attribute is used Transmission control protocol TCP connection whether has been established in description, second attribute is described for describing whether complete preposition instruction Third attribute is for describing whether target connection can be used, and the 4th attribute is for describing to finally receive user's control message Time;
After success establishes TCP connection with the server, the value of first attribute is revised as the second target value;
After success carries out the interaction of multiple preposition instructions with the server, by second attribute and the third attribute Value is revised as second target value, and the value of the 4th attribute is updated to current time, the multiple preposition instruction Including instruction of shaking hands, link order and creation stream instruction.
11. device according to claim 10, which is characterized in that the detection module is used for:
It attempts to read the user's control message that the server is sent;
When reading the user's control message that the server is sent, when the value of the 4th attribute is updated to current Between, determine that the state of the target connection is available mode;
When the unread user's control message sent to the server, according to the value of current time and the 4th attribute Between time interval, determine the state of target connection.
12. device according to claim 11, which is characterized in that the detection module is used for:
When time interval between current time and the value of the 4th attribute is greater than prefixed time interval, the target is determined The state of connection is down state, and the prefixed time interval was greater than between the time that the server sends user's control message Every;
When time interval between current time and the value of the 4th attribute is less than the prefixed time interval, suspend mode first After preset duration, by the step of executing the user's control message for attempting to read the server transmission, determine that the target connects The state connect, the corresponding time interval of first preset duration were less than between the time that the server sends user's control message Every.
13. device according to claim 12, which is characterized in that the detection module is also used to when target connection When state is available mode, after the first preset duration of suspend mode, continues to execute and attempt to read the user's control that the server is sent The step of message.
14. device according to claim 10, which is characterized in that it is described establish module for when the target connect shape When state is down state, after the second preset duration of suspend mode, the TCP connection is closed, the built in advance connecting object is deleted, is arranged The built in advance connecting object pointer variable is sky, re-executes the step of pre-establishing target connection.
15. device according to claim 10, which is characterized in that the acquisition module is used for:
When receiving the Media Stream acquisition instruction to any direct broadcast band, stream address and the stream name of the direct broadcast band are obtained Claim;
When the built in advance connecting object pointer variable is not empty, and the value of the third attribute is second target value, It is connected based on the target, sends play instruction to the server, receive the Media Stream that the server is sent, the broadcasting Instruction carries the stream title and traffic identifier, and the traffic identifier is obtained from the response results of the creation stream instruction.
16. device according to claim 15, which is characterized in that the acquisition module is also used to when built in advance connection pair When as pointer variable being empty, it is based on the stream address, obtains Media Stream from the server;Or,
The acquisition module is also used to when the built in advance connecting object pointer variable not be empty, and the value of the third attribute is When the first object value, it is based on the stream address, obtains Media Stream from the server.
17. a kind of terminal, which is characterized in that including processor and memory;The memory, for storing computer program; The processor realizes that claim 1-8 is described in any item for executing the computer program stored on the memory Method and step.
18. a kind of computer readable storage medium, which is characterized in that be stored with computer in the computer readable storage medium Program realizes claim 1-8 described in any item method and steps when the computer program is executed by processor.
CN201811157395.0A 2018-09-30 2018-09-30 Media stream acquisition method and device Active CN109246123B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811157395.0A CN109246123B (en) 2018-09-30 2018-09-30 Media stream acquisition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811157395.0A CN109246123B (en) 2018-09-30 2018-09-30 Media stream acquisition method and device

Publications (2)

Publication Number Publication Date
CN109246123A true CN109246123A (en) 2019-01-18
CN109246123B CN109246123B (en) 2021-10-22

Family

ID=65054958

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811157395.0A Active CN109246123B (en) 2018-09-30 2018-09-30 Media stream acquisition method and device

Country Status (1)

Country Link
CN (1) CN109246123B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111294355A (en) * 2020-02-10 2020-06-16 浙江大华技术股份有限公司 Sub-connection creating method, client device and server device
CN112367367A (en) * 2020-10-27 2021-02-12 西安万像电子科技有限公司 Image management method, device and system
CN112770124A (en) * 2020-12-22 2021-05-07 Oppo广东移动通信有限公司 Method and device for entering live broadcast room, storage medium and electronic equipment
CN113038158A (en) * 2021-03-09 2021-06-25 北京高途云集教育科技有限公司 Object display method and device based on live broadcast, electronic equipment and medium
CN113824915A (en) * 2021-08-10 2021-12-21 深圳Tcl新技术有限公司 Video picture acquisition method, device and computer-readable storage medium
CN114006935A (en) * 2020-07-14 2022-02-01 成都鼎桥通信技术有限公司 Private network terminal network access method, device and equipment
CN114002488A (en) * 2021-09-29 2022-02-01 苏州浪潮智能科技有限公司 Automatic monitoring and adjusting method, device and system
CN114339296A (en) * 2022-03-02 2022-04-12 阿里巴巴(中国)有限公司 Method and device for transmitting media stream and media system
CN114844870A (en) * 2022-03-25 2022-08-02 阿里巴巴(中国)有限公司 Media stream acquisition method and device, electronic equipment and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101741743A (en) * 2009-12-11 2010-06-16 东南大学 Network address sort-based bidirectional stream combining method
CN102270207A (en) * 2010-06-02 2011-12-07 中国科学院计算技术研究所 Online multimedia information mining oriented data caching method and system
CN102523531A (en) * 2011-12-08 2012-06-27 深圳市同洲视讯传媒有限公司 Access entity which processes session in video on demand system and method thereof
CN103152134A (en) * 2013-02-26 2013-06-12 汉柏科技有限公司 Real time protocol (RTP)-based method and system for rearranging voice packets at receiving end
CN103685241A (en) * 2013-11-26 2014-03-26 中国科学院计算技术研究所 Adaptive heartbeat method and adaptive heartbeat system for maintaining long connection of TCP (transmission control protocol)
CN104184944A (en) * 2014-08-15 2014-12-03 小米科技有限责任公司 Method and device for obtaining multimedia data streams
CN104935958A (en) * 2015-06-24 2015-09-23 青岛科技大学 Real-time video transmission device and method
US20160323352A1 (en) * 2015-04-28 2016-11-03 Fortinet, Inc. Web proxy
CA2998320A1 (en) * 2015-09-14 2017-03-23 Viasat, Inc. Machine-driven crowd-disambiguation of data resources
CN107396431A (en) * 2017-06-19 2017-11-24 努比亚技术有限公司 Connect keeping method, connection keeps equipment and computer-readable recording medium
CN107820100A (en) * 2017-10-30 2018-03-20 北京四达时代软件技术股份有限公司 internet audio and video playing method and device

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101741743A (en) * 2009-12-11 2010-06-16 东南大学 Network address sort-based bidirectional stream combining method
CN102270207A (en) * 2010-06-02 2011-12-07 中国科学院计算技术研究所 Online multimedia information mining oriented data caching method and system
CN102523531A (en) * 2011-12-08 2012-06-27 深圳市同洲视讯传媒有限公司 Access entity which processes session in video on demand system and method thereof
CN103152134A (en) * 2013-02-26 2013-06-12 汉柏科技有限公司 Real time protocol (RTP)-based method and system for rearranging voice packets at receiving end
CN103685241A (en) * 2013-11-26 2014-03-26 中国科学院计算技术研究所 Adaptive heartbeat method and adaptive heartbeat system for maintaining long connection of TCP (transmission control protocol)
CN104184944A (en) * 2014-08-15 2014-12-03 小米科技有限责任公司 Method and device for obtaining multimedia data streams
US20160323352A1 (en) * 2015-04-28 2016-11-03 Fortinet, Inc. Web proxy
CN104935958A (en) * 2015-06-24 2015-09-23 青岛科技大学 Real-time video transmission device and method
CA2998320A1 (en) * 2015-09-14 2017-03-23 Viasat, Inc. Machine-driven crowd-disambiguation of data resources
CN107396431A (en) * 2017-06-19 2017-11-24 努比亚技术有限公司 Connect keeping method, connection keeps equipment and computer-readable recording medium
CN107820100A (en) * 2017-10-30 2018-03-20 北京四达时代软件技术股份有限公司 internet audio and video playing method and device

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111294355A (en) * 2020-02-10 2020-06-16 浙江大华技术股份有限公司 Sub-connection creating method, client device and server device
CN114006935B (en) * 2020-07-14 2023-11-21 成都鼎桥通信技术有限公司 Private network terminal network access method, device and equipment
CN114006935A (en) * 2020-07-14 2022-02-01 成都鼎桥通信技术有限公司 Private network terminal network access method, device and equipment
CN112367367A (en) * 2020-10-27 2021-02-12 西安万像电子科技有限公司 Image management method, device and system
CN112367367B (en) * 2020-10-27 2024-06-07 西安万像电子科技有限公司 Image management method, device and system
CN112770124A (en) * 2020-12-22 2021-05-07 Oppo广东移动通信有限公司 Method and device for entering live broadcast room, storage medium and electronic equipment
CN112770124B (en) * 2020-12-22 2023-10-31 Oppo广东移动通信有限公司 Method and device for entering live broadcast room, storage medium and electronic equipment
CN113038158A (en) * 2021-03-09 2021-06-25 北京高途云集教育科技有限公司 Object display method and device based on live broadcast, electronic equipment and medium
CN113038158B (en) * 2021-03-09 2022-11-22 北京高途云集教育科技有限公司 Object display method and device based on live broadcast, electronic equipment and medium
CN113824915A (en) * 2021-08-10 2021-12-21 深圳Tcl新技术有限公司 Video picture acquisition method, device and computer-readable storage medium
CN113824915B (en) * 2021-08-10 2024-04-05 深圳Tcl新技术有限公司 Video picture acquisition method, apparatus and computer readable storage medium
CN114002488B (en) * 2021-09-29 2024-01-16 苏州浪潮智能科技有限公司 Automatic monitoring and adjusting method, device and system
CN114002488A (en) * 2021-09-29 2022-02-01 苏州浪潮智能科技有限公司 Automatic monitoring and adjusting method, device and system
CN114339296A (en) * 2022-03-02 2022-04-12 阿里巴巴(中国)有限公司 Method and device for transmitting media stream and media system
CN114844870A (en) * 2022-03-25 2022-08-02 阿里巴巴(中国)有限公司 Media stream acquisition method and device, electronic equipment and storage medium
CN114844870B (en) * 2022-03-25 2024-03-26 阿里巴巴(中国)有限公司 Media stream acquisition method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN109246123B (en) 2021-10-22

Similar Documents

Publication Publication Date Title
CN109246123A (en) Media stream capturing method and device
CN109982102A (en) The interface display method and system and direct broadcast server of direct broadcasting room and main broadcaster end
CN108966008A (en) Live video back method and device
CN112118477B (en) Virtual gift display method, device, equipment and storage medium
CN110213608A (en) Show method, apparatus, equipment and the readable storage medium storing program for executing of virtual present
CN110674022A (en) Behavior data acquisition method and device and storage medium
CN108833963A (en) Method, computer equipment, readable storage medium storing program for executing and the system of display interface picture
CN109302385A (en) Multimedia resource sharing method, device and storage medium
CN109194972A (en) Live stream acquisition methods, device, computer equipment and storage medium
CN109327608A (en) Method, terminal, server and the system that song is shared
CN107888968A (en) Player method, device and the computer-readable storage medium of live video
CN109413453A (en) Video broadcasting method, device, terminal and storage medium
CN110278464A (en) The method and apparatus for showing list
CN111596885B (en) Audio data processing method, server and storage medium
CN113542290B (en) Data access request processing method, device, equipment and readable storage medium
CN108762881A (en) Interface method for drafting, device, terminal and storage medium
CN107896337B (en) Information popularization method and device and storage medium
CN110213612A (en) Living broadcast interactive method, apparatus and storage medium
CN110418152A (en) It is broadcast live the method and device of prompt
CN109922356A (en) Video recommendation method, device and computer readable storage medium
CN110276034A (en) Content item methods of exhibiting, device, computer equipment and storage medium
CN108579075B (en) Operation request response method, device, storage medium and system
WO2020244516A1 (en) Online interaction method and device
CN109246228A (en) Resource acquisition, resource allocation methods, device, equipment and storage medium
CN109783176A (en) Switch the method and apparatus of the page

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant