Live streaming management method, device, electronic device and storage medium
By instantiating the objects in the live stream management class when the live broadcast page is opened, and calling the corresponding methods to obtain, decode and render the live stream, the existing technology problems of high code coupling, poor reusability and poor real-time performance of live video are solved. , achieving more efficient live stream processing and improved user experience.
Patent Information
- Application Number
- CN202110063707.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-18
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2041-01-18
AI Technical Summary
In the existing media live video stream processing method, the callback function is directly called through the media playback interface, resulting in high code coupling, poor reusability, and poor real-time performance of live video playback, which affects the user experience.
When it is detected that the live broadcast page is open, the preset initialization method encapsulated in the live stream management class is called to instantiate the live stream interface object, live stream playback object, and interface display object. Call the live stream connection method through the instantiated live stream interface object to obtain the live stream, decode it through the live stream playback object, and render the decoded live stream to the preset view.
It reduces the coupling degree of the code, improves the reusability of the code, and improves the efficiency of live stream processing, thus improving the user experience.
Smart Images

Figure CN114827741B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a live streaming management method, device, electronic device, and storage medium. Background Art
[0002] In the existing methods for processing live media video streams, it is usually implemented directly through the media playback interface, and the callback function of the media playback interface needs to be called during the implementation process. However, the number of callback functions of the media playback interface is large, the control difficulty is large, the complexity is high when using, and the difficulty coefficient of use is high. In the development process, directly calling the callback function through the media playback interface makes the coupling degree between codes high and the reusability of the code poor. In the process of code testing and execution, directly calling the callback function through the media playback interface is prone to abnormal problems such as throwing status errors, which reduces the efficiency of software development. In addition, when playing the live media video stream, the real-time performance of the live video playback is poor, which greatly affects the user experience. Summary of the invention
[0003] The embodiments of the present invention provide a live streaming management method, device, electronic device and storage medium, which can reduce code coupling, improve code reusability, and improve the efficiency of live streaming processing, thereby improving user experience.
[0004] In a first aspect, an embodiment of the present invention provides a live streaming management method, the method comprising:
[0005] When it is detected that the live page is opened, a preset initialization method encapsulated in the live stream management class is called to instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class;
[0006] By instantiating the live stream interface object, calling the live stream connection method with the address of the live stream as the entry parameter, the live stream of the live page is obtained;
[0007] By calling the instantiated live stream playback object, a decoding method with the height and width corresponding to the decoded live stream as input parameters is used to decode the live stream to obtain the decoded live stream;
[0008] Through the instantiated live stream playback object, the live stream rendering method with the instantiated interface display object as the entry parameter is called to render the decoded live stream to the preset view of the live page.
[0009] In a second aspect, an embodiment of the present invention further provides a live stream management device, the device comprising:
[0010] The instantiation object module is used to call the preset initialization method encapsulated in the live stream management class when detecting that the live stream page is opened, and instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class;
[0011] A live stream acquisition module, used to call a live stream connection method with the address of the live stream as an entry parameter through an instantiated live stream interface object, so as to acquire the live stream of the live page;
[0012] A live stream decoding module is used to call a decoding method with a height and a width corresponding to the decoded live stream as input parameters through an instantiated live stream playback object, decode the live stream, and obtain a decoded live stream;
[0013] The view rendering module is used to call the live stream rendering method with the instantiated interface display object as the entry parameter through the instantiated live stream playback object, and render the decoded live stream to the preset view of the live page.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0015] one or more processors;
[0016] A storage device is used to store one or more programs. When the program is executed by the processor, the processor implements the live streaming management method provided by any embodiment of the present invention.
[0017] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the live stream management method as provided in any embodiment of the present invention.
[0018] The technical solution of the embodiment of the present invention is to call the preset initialization method encapsulated in the live stream management class when detecting that the live page is opened, and instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class. Through the instantiated live stream interface object, call the live stream connection method with the address of the live stream as the entry parameter to obtain the live stream of the live page, thereby obtaining the live stream. Through the instantiated live stream playback object, call the decoding method with the height and width corresponding to the decoded live stream as the entry parameters to decode the live stream and obtain the decoded live stream.
[0019] Through the instantiated live stream playback object, the live stream rendering method with the instantiated interface display object as the entry parameter is called, and the decoded live stream is rendered to the preset view of the live page to achieve live stream playback. By instantiating the pre-defined objects in the live management class, it is possible to apply for memory space for the class corresponding to each object, so that the data and methods in the class can be called, realizing code decoupling, thereby achieving a low coupling effect between classes. By calling the live stream connection method with the address of the live stream as the entry parameter, and by calling the decoding method with the height and width corresponding to the decoded live stream as the entry parameter, the reusability of the code is achieved. By calling the preset initialization method encapsulated in the live stream management class when detecting that the live page is opened, the live stream processing efficiency is improved, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required to describe the embodiments. Obviously, the drawings introduced are only drawings of a part of the embodiments to be described in the present invention, rather than all the drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 It is a flowchart of a live streaming management method provided by Embodiment 1 of the present invention;
[0022] Figure 2 It is a flowchart of a live streaming management method provided by Embodiment 2 of the present invention;
[0023] Figure 3 It is a module diagram of a live streaming management device provided by Embodiment 4 of the present invention;
[0024] Figure 4 It is a structural schematic diagram of an electronic device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0026] Embodiment 1
[0027] Figure 1It is a flowchart of a live stream management method provided in Embodiment 1 of the present invention. This embodiment is applicable to the situation where the live stream is managed by calling the method of the live stream management class when the live stream page is detected to be opened. The method can be executed by a live stream management device. The live stream management device can be implemented by software and / or hardware. The live stream management device can be integrated into a client system and installed in electronic devices such as mobile phones and computers along with the client system.
[0028] like Figure 1 As shown, the method of this embodiment includes:
[0029] S110. When it is detected that the live page is opened, a preset initialization method encapsulated in the live stream management class is called to instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class.
[0030] Among them, an object can be understood as a combination of data and actions. Object information can include object name and object type. Encapsulation can be understood as combining abstracted data and behaviors to form an organic whole. The benefits of encapsulation are that it can enhance security and simplify programming. Instantiating an object can be understood as: opening up memory space for an object.
[0031] Among them, class is the basis for object-oriented programming to realize information encapsulation. Each class can include data description and a set of methods for operating data or transmitting messages. The relationship between classes can be an inheritance relationship. For example, class A inherits class B, where class B is called the parent class of class A, and class A is called the subclass of class B.
[0032] In this example, the live stream management class can be a class pre-customized by the developer, which can be used to manage the live stream. The live stream management class can inherit the BaseManager class, that is, it can be understood that the parent class of the live stream management class can be the BaseManager class, that is, the live stream management class can be a subclass of the BaseManager class. Among them, the BaseManager class encapsulates the common callback methods of the system. The advantage of the live stream management class inheriting the BaseManager class is that the live stream management class can override the callback methods in the base management class, thereby realizing the quick access to the live stream management functions.
[0033] Among them, the number of predefined objects in the live stream management class can be one or more. In this embodiment, the predefined objects in the live stream management class can include a live stream interface object, a live stream playback object, and an interface display object, and the live stream interface object, the live stream playback object, and the interface display object are initialized to empty. Among them, the live stream interface object can be a private object of the interface type (SDInterface type), which can be used to process live stream information. The live stream playback object can be a private object of the playback interface type (SDInterfacePlayer type), which can be used to decode the video stream. The interface display object can be a private object of the surface view renderer type (SurfaceViewRenderer type), which can be used to render the live stream.
[0034] Exemplarily, according to the syntax rules of object initialization definition, the objects are initialized by using the keywords private and var. The sdInterface object is initialized by the private var sdInterface:SDInterface? = null statement; the sdPlayer is initialized by the private var sdPlayer:SDInterfacePlayer? = null statement; and the surfaceView object is initialized by the private var surfaceView:SurfaceViewRenderer? = null statement.
[0035] It should be noted that a class is essentially a data type, that is, the SDInterface class can be understood as the SDInterface type, the SDInterfacePlayer class can be understood as the SDInterfacePlayer type, and the SurfaceViewRenderer class can be understood as the SurfaceViewRenderer type.
[0036] Among them, the methods in the live stream management class can be one or more. The methods in the live stream management class can include customized methods and methods in the overridden parent class. In this embodiment, the preset initialization method encapsulated in the live stream management class can be an initialization method (onActivityCreate method) in the BaseManager class that is overridden by the keyword Override. Through the preset initialization method, when the client system detects that the live page is opened, the event of the live page opening will be encapsulated into an event object, and then the event object will be passed to the function function that handles the event through a system callback. In other words, the event object is passed to the onActivityCreate method in the live stream management class through a system callback. Thus, the pre-defined live stream interface object (sdInterface), live stream playback object (sdPlayer) and interface display object (surfaceView) can be instantiated through the onActivityCreate method in the live stream management class.
[0037] It should be noted that in the onActivityCreate method in the live stream management class, after instantiating the preset object, it is necessary to call the initialization method in the SDInterface class through the live stream interface object to initialize the internal functions of the live stream interface object. For example, the initialization method in the SDInterface class is SDsysinit(), that is, the initialization of the internal functions of the live stream interface object is realized by calling sdInterface?.SDsysinit(). The reason for this is that the methods in the SDInterface class can be used only after calling the initialization method in the SDInterface class.
[0038] Specifically, a live stream management class that inherits BaseManager is predefined. The live stream interface object, live stream playback object, and interface display object are predefined in the live stream management class, and the onActivityCreate method of the BaseManager class is pre-overridden in the live stream management class. When the detection module of the client detects that a live page opening event occurs when a user clicks or touches, the onActivityCreate method in the live stream management class is automatically called to instantiate the live stream interface object, live stream playback object, and interface display object.
[0039] S120. Call a live stream connection method with the address of the live stream as an entry parameter through the instantiated live stream interface object to obtain the live stream of the live page.
[0040] Among them, the live stream connection method can be a method that the developer pre-customized in the SDInterface class, such as defining the live stream connection method as the SDConnectRtmp method. The live stream connection method can be used to obtain the live stream. The address of the live stream can be understood as the storage address corresponding to the live stream. The entry parameter of the live stream connection method can be understood as the formal parameter of the live stream connection method, which is used to receive the address of the live stream passed when calling the live stream connection method, thereby obtaining the live stream address corresponding to the live page.
[0041] Specifically, the live stream service connection method is defined in advance in the live stream management class by the keyword fun, such as funconnectRtmpServer(). The entry parameter of the live stream service connection method may be the address of the live stream (such as streamUrl), and the data type of the entry parameter may be a string type, that is, the type of the live stream address may be a string, for example, fun connectRtmpServer(streamUrl:String).
[0042] Specifically, after calling the onActivityCreate method in the live stream management class, the live stream interface object can be instantiated to obtain the instantiated live stream interface object. By calling the predefined live stream service connection method, in the predefined live stream service connection method, the live stream connection method with the live stream address as the entry parameter is called through the instantiated live stream interface object, so as to obtain the live stream corresponding to the live page.
[0043] S130. Call a decoding method with a height and a width corresponding to the decoded live stream as input parameters through the instantiated live stream playback object, decode the live stream, and obtain a decoded live stream.
[0044] The decoding method may be a method that the developer pre-defined in the SDInterfacePlayer class, such as defining the decoding method as the SDStartPlay method. The decoding method may be used to decode the live stream. The entry parameter of the decoding method may be a formal parameter corresponding to the height and width of the decoded live stream, which is used to receive the actual parameters corresponding to the height and width of the decoded live stream passed when calling the decoding method, thereby decoding the video stream.
[0045] Specifically, the live stream start decoding method is defined in advance in the live stream management class through the keyword fun, such as funstartStrean(). Among them, the entry parameter of the live stream start decoding method can be a formal parameter corresponding to the height and width of the decoded live stream (such as rendWidth and rendHeight), and the data type of the entry parameter can be an integer type, that is, the data type of the height of the decoded live stream is an integer, and the data type of the width of the decoded live stream is an integer. For example, fun startStrean(rendWidth: Int, rendHeight: Int). The live stream start decoding method in the live stream management class calls the decoding method in the SDInterfacePlayer class to implement the decoding of the video stream. The advantage of this processing is that it reduces the coupling between the live stream management class and the SDInterfacePlayer class, improves the reusability of the code in the SDInterfacePlayer class, and thus improves the efficiency of code development.
[0046] Specifically, after calling the onActivityCreate method in the live stream management class, the live stream playback object can be instantiated to obtain the instantiated live stream playback object. After obtaining the live stream corresponding to the live page, the live stream start decoding method is called with the predefined entry parameters as the height and width of the decoded live stream. In the predefined live stream start decoding method, the instantiated live stream playback object is used to call the decoding method with the height and width corresponding to the decoded live stream as entry parameters, thereby decoding the live stream and obtaining the decoded live stream.
[0047] S140. Call a live stream rendering method with an instantiated interface display object as an entry parameter through the instantiated live stream playback object, and render the decoded live stream to a preset view of the live page.
[0048] Among them, the live stream rendering method can be a method that the developer pre-customized in the SDInterfacePlayer class, such as defining the live stream rendering method as the SDplayinit method. The entry parameters of the live stream rendering method may include an instantiated interface display object and a getActivity method. Among them, using the getActivity method, the information of the control or window in the live page can be obtained, so as to render the decoded live stream to the window of the live page used for live broadcast. The live stream decoding method can be used to render the decoded live stream into the view, that is, the live stream decoding method establishes a binding relationship between the instantiated interface display object and the decoded live stream playback object, thereby realizing the rendering of the decoded live stream playback object to the view corresponding to the instantiated interface display object.
[0049] Specifically, the live stream rendering view corresponding to the live page is pre-set. After calling the onActivityCreate method in the live stream management class, the interface display object can be instantiated to obtain the instantiated interface display object. After obtaining the decoded live stream, the live stream rendering method with pre-defined entry parameters as the instantiated interface display object and the getActivity method is called through the instantiated live stream playback object, and the decoded live stream is rendered to the preset view of the live page, thereby realizing the playback of the live stream on the live page.
[0050] The technical solution of the embodiment of the present invention is to call the preset initialization method encapsulated in the live stream management class when detecting that the live page is opened, and instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class. Through the instantiated live stream interface object, call the live stream connection method with the address of the live stream as the entry parameter to obtain the live stream of the live page, thereby obtaining the live stream. Through the instantiated live stream playback object, call the decoding method with the height and width corresponding to the decoded live stream as the entry parameters to decode the live stream and obtain the decoded live stream.
[0051] Through the instantiated live stream playback object, the live stream rendering method with the instantiated interface display object as the entry parameter is called, and the decoded live stream is rendered to the preset view of the live page to achieve live stream playback. By calling the preset initialization method encapsulated in the live stream management class when detecting that the live page is opened, the live stream processing efficiency is improved, thereby improving the user experience. By instantiating the pre-defined objects in the live management class, memory space can be applied for the class corresponding to each object, so that the data and methods in the class can be called, code decoupling is achieved, and low coupling between classes is achieved. Code reusability is achieved by calling the live stream connection method with the address of the live stream as the entry parameter, and by calling the decoding method with the height and width corresponding to the decoded live stream as the entry parameters.
[0052] Embodiment 2
[0053] Figure 2This is a flow chart of a live stream management method provided by the second embodiment of the present invention. Based on the above embodiment, the present embodiment can send a request to the server to obtain the address of the live stream before obtaining the live stream of the live page through the instantiated live stream interface object and calling the live stream connection method with the address of the live stream as the entry parameter, so as to obtain the live stream. In addition, after rendering the decoded live stream to the preset view of the live page, the resources corresponding to the live stream interface object and the live stream playback object can be released, which can avoid client memory leakage and resource waste.
[0054] like Figure 2 As shown, the method of this embodiment may specifically include:
[0055] S210. When it is detected that the live page is opened, a preset initialization method encapsulated in the live stream management class is called to instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class.
[0056] S220: Send a live stream address request to the server, so that the server feeds back the live stream address.
[0057] The server may be used to store the live stream and the corresponding address of the live stream.
[0058] Specifically, after the live stream interface object, the live stream playback object, and the interface display object are instantiated, the client obtains the address of the current live page. The client generates an address request for the live stream of the current live page according to the address of the current live page. The client sends an address request corresponding to the live stream of the current page to the server according to the address request corresponding to the live stream of the current page, so that the server sends the live stream address corresponding to the address request corresponding to the live stream of the current page to the client according to the address request corresponding to the live stream of the current page.
[0059] S230: Determine whether the content corresponding to the address of the live stream is empty by calling a parameter content determination method; if not, receive the address of the live stream fed back by the server.
[0060] The parameter content judgment method can be used to judge whether the content of the live stream address is an empty string, and the parameter content judgment method can be the isEmpty method. The return value type of the parameter content judgment method is a Boolean type, and accordingly, the return value of the parameter content judgment method can include true and false. If the return value of the parameter content judgment method is true, it means that the content corresponding to the address of the current live stream is empty; if the return value of the parameter content judgment method is false, it means that the content corresponding to the address of the current live stream is not empty.
[0061] Specifically, when the live streaming address corresponding to the live streaming page sent by the server to the client, or after the live streaming address corresponding to the live streaming page sent by the server to the client, the parameter content judgment method can be called through the live streaming address to determine whether the live streaming address received by the client is an empty string. When the return value of the parameter content judgment method is false, the client receives the live streaming address corresponding to the live streaming page sent by the server. Optionally, when the return value of the parameter content judgment method is true, it means that the live streaming address corresponding to the live streaming page sent by the server is empty, that is, the live streaming address corresponding to the live streaming page sent by the server is invalid, then S220 is executed, so that the client receives the valid live streaming address fed back by the server.
[0062] S240. Call a live stream connection method with the address of the live stream as an entry parameter through the instantiated live interface object, and determine whether the live stream connection method is successfully connected.
[0063] Among them, the live stream connection method can be used to obtain the live stream. The return value type of the live stream connection method is Boolean type (Boolean), for example, fun connectRtmpServer(streamUrl:String):Boolean{}, and accordingly, the return value of the live stream connection method can include true and false. Among them, if the return value of the live stream connection method is true, it means that the live stream connection is successful; if the return value of the live stream connection method is false, it means that the live stream connection fails. The live stream connection method in the live stream management class calls the live stream connection method with the address of the live stream as the entry parameter through the instantiated live interface object to determine whether the live stream is successfully connected. The benefit is: reducing the coupling between the live stream management class and the SDInterface class, improving the reusability of the code in the SDInterface class, thereby improving the efficiency of code development.
[0064] Specifically, when the client receives the live stream address fed back by the server, or after the client receives the live stream address fed back by the server. The address of the live stream fed back by the server is passed as an actual parameter to the live stream connection method with the address of the live stream as the entry parameter. When it is detected that the entry parameter of the live stream connection method is an actual parameter, the live stream connection method is called through the instantiated live stream interface object. By executing the call to the live stream connection method, the return value of the live stream connection method is determined. According to the return value of the live stream connection method, it is judged whether the live stream is connected successfully. If the return value of the live stream connection method is true, it means that the live stream connection is successful; if the return value of the live stream connection method is false, it means that the live stream connection failed.
[0065] S250: If the live stream connection is successful, the live stream of the live page is obtained.
[0066] Among them, the live stream connection success can be understood as the return value of the live stream connection method is true.
[0067] Specifically, when it is detected that the return value of the live stream connection method is true, the live stream of the live page is obtained.
[0068] S260. Call a decoding method with the height and width corresponding to the decoded live stream as input parameters through the instantiated live stream playback object to decode the live stream and obtain the decoded live stream.
[0069] S270: Call a live stream rendering method with an instantiated interface display object as an entry parameter through the instantiated live stream playback object, and render the decoded live stream to a preset view of the live page.
[0070] S280: When it is detected that the live page is closed, a resource release method encapsulated in the live stream management class is called to release resources corresponding to the live stream interface object and the live stream playback object.
[0071] The resource release method can be a resource release method of the BaseManager class that is pre-overridden in the live stream management class, such as override fun onActivityFinish(){}. The resource release method in the live stream management class can be used to release the resources occupied during the live stream control process when the live page is closed. The benefit of releasing resources is that it can realize resource recycling and avoid memory leaks on the client.
[0072] The resources occupied by the live stream interface object can be understood as the related threads occupied by the live stream interface object for processing the live stream. The method for releasing the resources corresponding to the live stream interface object can be: pre-defining the method for releasing the resources corresponding to the live stream interface object in the SDInterface class, such as SDsysexit(). The implementation method for releasing the resources corresponding to the live stream interface object can be: calling the method for releasing the resources corresponding to the live stream interface object through the live stream interface object, such as sdInterface?.SDsysexit().
[0073] The resources occupied by the live stream playback object can be understood as the related threads occupied by the live stream playback object for processing live stream decoding. The method for releasing the resources corresponding to the live stream playback object can be: pre-defining a method for releasing the resources corresponding to the live stream playback object in the SDInterfacePlayer class, such as SDplayexit(). The implementation method for releasing the resources corresponding to the live stream playback object can be: calling the method for releasing the resources corresponding to the live stream playback object through the live stream playback object, such as sdPlayer?.SDplayexit().
[0074] Specifically, after rendering the decoded live stream to the preset view of the live page, the detection module of the client automatically calls the onActivityFinish method in the live stream management class when it detects that the user clicks or touches to close the live page. In the onActivityFinish method, the method for releasing the resources corresponding to the live stream interface object is called through the live stream interface object, and the method for releasing the resources corresponding to the live stream playback object is called through the live stream playback object, thereby releasing the resources corresponding to the live stream interface object and the live stream playback object.
[0075] The technical solution of this embodiment is to call the live stream connection method with the address of the live stream as the entry parameter in the instantiated live stream interface object, and before obtaining the live stream of the live page, send the address request of the live stream to the server, so that the server can feedback the address of the live stream. By calling the parameter content judgment method, it is judged whether the content corresponding to the address of the live stream is empty. If the content corresponding to the address of the live stream is not empty, the address of the live stream fed back by the server is received, so that the client obtains the address of the valid live stream of the live stream corresponding to the live page. Through the instantiated live interface object, the live stream connection method with the address of the live stream as the entry parameter is called, and it is judged whether the live stream connection method is successfully connected. If the live stream connection is successful, the live stream of the live page is obtained, so that the live page of the client obtains the live stream in real time. And by releasing the resources corresponding to the live stream interface object and the live stream playback object after rendering the decoded live stream to the preset view of the live page, it can reduce client memory leakage and resource waste.
[0076] In addition, the live streaming management method proposed in the embodiment of the present invention and the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0077] Embodiment 3
[0078] A live stream management method provided in embodiment 3 of the present invention optimizes the steps of instantiating pre-defined live stream interface objects, live stream playback objects, and interface display objects in the live stream management class on the basis of the previous embodiments, thereby reducing the coupling degree of the code, improving the reusability of the code, and improving the efficiency of software development.
[0079] The method of this embodiment may specifically include:
[0080] S310: When it is detected that the live page is opened, a preset initialization method encapsulated in the live stream management class is called to instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class.
[0081] Optionally, the pre-defined live stream interface object in the live stream management class is instantiated, including: initializing the message passing object and live stream interface object pre-defined in the live stream management class to empty based on the initialization statement; obtaining the object information of the live page by calling the object information acquisition method of the page; passing the object information of the live page to the initialized message passing object to obtain the message passing object corresponding to the live page; using the message passing object corresponding to the live page as the entry parameter of the live stream interface object instantiation method; and instantiating the initialized live stream interface object by calling the live stream interface object instantiation method.
[0082] A message control class is predefined, wherein the message control class may be a subclass that inherits the Handler class, for example, the MyHandler class. The message passing object may be a private object of the message control type, such as private varhandler:MyHandler. Accordingly, the message passing object may be initialized to null as follows: private var handler:MyHandler? = null. The message passing object may be used for message passing between threads. The initialization statement may be a statement that needs to be executed when the object is initialized. The reason for initializing the object is to allocate space for the object. The benefit of initializing the object to null is to avoid wasting memory and reduce the occurrence of abnormal problems.
[0083] Among them, the object information acquisition method of the page can be a getActivity method, wherein the getActivity method is a method encapsulated in a predefined message control class. The message passing object is instantiated by calling the constructor of the message control class to obtain the message passing object corresponding to the live page. Among them, the entry parameter of the constructor of the message control class can be the object information acquisition method of the page, such as MyHandler(getActivity()). The object information acquisition method of the page can be used to obtain the object information of the page such as the space or window information in the live page, so as to pass the object information of the live page to the initialized message passing object, so that the message passing object obtains the object information corresponding to the live page.
[0084] Among them, the live streaming interface object instantiation method can be the construction method of the SDInterface class, that is, the construction method of the SDInterface class can be SDInterface(). The live streaming interface object instantiation method can be used to instantiate the initialized live streaming interface object. The entry parameter of the live streaming interface object instantiation method can be the message passing object corresponding to the live page, such as SDInterface(handler). Correspondingly, the instantiation of the live streaming interface object can be sdInterface=SDInterface(handler).
[0085] Specifically, instantiating the predefined live stream interface object in the live stream management class can be: the message passing object and the live stream interface object predefined in the live stream management class are initialized to empty according to the object initialization statement. When it is detected whether the initialized message passing object is empty, the object information of the live page is obtained by calling the object information acquisition method of the page, and the object information of the live page is used as the entry parameter of the message control class construction method. By calling the message control class construction method, the initialized message passing object is instantiated to obtain the message passing object corresponding to the live page. When it is detected that the initialized live stream interface object is empty and the message passing object corresponding to the live page is non-empty, the message passing object corresponding to the live page is used as the actual parameter and passed to the entry parameter of the live stream interface object instantiation method. The initialized live stream interface object is instantiated by calling the live stream interface object instantiation method. Optionally, a pre-defined live stream playback object in the live stream management class is instantiated, including: based on the factory design pattern, pre-creating a factory class of a live stream playback object to obtain a factory method of the live stream playback object; and instantiating the live stream playback object by calling the factory method of the live stream playback object.
[0086] Among them, the factory design pattern can be understood as a pattern for creating objects. The advantage of using the factory design pattern to create objects is the later maintenance of the code, reducing the coupling between codes, and realizing unified management of objects.
[0087] The factory class of the live stream player object may be a predefined factory class, such as PlayerFactory. The factory class of the live stream player object may include a factory method of the live stream player object, such as getPlayer(). The live stream player object is instantiated by calling the factory method of the live stream player object in the factory class through the keyword instance, such as sdPlayer = PlayerFactory.instance.getPlayer().
[0088] Specifically, the instantiation of the predefined live stream playback object in the live stream management class can be: according to the factory design pattern, predefine the object creation factory interface. Pre-create a factory class for a live stream playback object, and use the keyword implements to make the factory class of the live stream playback object implement the object creation factory interface, thereby obtaining the factory method of the live stream playback object. Pre-defined live stream playback object. Based on the object initialization statement, the pre-defined live stream playback object is initialized to empty to obtain the initialized live stream playback object. When it is detected that the initialized live stream playback object is empty, the factory method of the live stream playback object can be called to instantiate the initialized live stream playback object.
[0089] It should be noted that the method of detecting whether the initialized message transmission object is empty, detecting whether the initialized live stream interface object is empty, and detecting whether the initialized live stream playback object is empty can be determined through an if judgment statement.
[0090] Optionally, a predefined interface display object in the live stream management class is instantiated, including: obtaining the identifier of the live page by calling the page identifier acquisition method of the page object information acquisition method; binding the live page identifier to the interface display object, and instantiating the interface display object.
[0091] Among them, the page identifier acquisition method can be used to obtain the page identifier of the current live page. The page identifier acquisition method can be a findViewById method. The entry parameters of the page identifier acquisition method can include a live page identifier and an interface display object. Among them, the interface display object can be an initialized interface display object. Exemplarily, the method for instantiating a predefined interface display object can be: surfaceView = getActivity().findViewById(R.id.surface_view), wherein R represents resources, R.id represents page identifier, and R.id.surface_view represents the interface display object of the page identifier. The page identifier is bound to the interface display by calling getActivity().findViewById(R.id.surface_view), thereby instantiating the interface display object, that is, surfaceView = getActivity().findViewById(R.id.surface_view).
[0092] Specifically, in the live stream management class, the predefined interface display object is instantiated as follows: the predefined interface display object. Based on the object initialization statement, the predefined interface display object is initialized to empty to obtain the initialized interface display object. The binding logic between the initialized interface display object and the page identifier is defined in advance in the page identifier acquisition method. By calling the page identifier acquisition method of the object information acquisition method of the page, the initialized interface display object is bound to the page identifier, thereby instantiating the interface display object.
[0093] S320. Through the instantiated live stream interface object, call the live stream connection method with the address of the live stream as the entry parameter to obtain the live stream of the live page.
[0094] S330: Call a decoding method with the height and width corresponding to the decoded live stream as input parameters through the instantiated live stream playback object, decode the live stream, and obtain the decoded live stream.
[0095] S340: Through the instantiated live stream playback object, call the live stream rendering method with the instantiated interface display object as the entry parameter, and render the decoded live stream to the preset view of the live page.
[0096] The technical solution of this embodiment is to instantiate the initialized live stream interface object by calling the live stream interface object instantiation method in the live stream management class; to instantiate the live stream playback object by calling the factory method of the live stream playback object based on the factory design pattern; to obtain the identifier of the live page by calling the page identifier acquisition method of the page object information acquisition method; to bind the live page identifier to the interface display object and instantiate the interface display object, thereby achieving the effect of reducing the coupling degree of the code, improving the reusability of the code, and improving the software development efficiency.
[0097] In addition, the live streaming management method proposed in the embodiment of the present invention and the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0098] Embodiment 4
[0099] Figure 3 It is a module diagram of a live stream management device provided in Embodiment 4 of the present invention. The present invention provides a live stream management device, which includes: an instantiation object module 310, a live stream acquisition module 320, a live stream decoding module 330 and a view rendering module 340.
[0100] Among them, the instantiation object module 310 is used to call the preset initialization method encapsulated in the live stream management class when it detects that the live broadcast page is opened, and instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class.
[0101] The live stream acquisition module 320 is used to call the live stream connection method with the address of the live stream as the entry parameter through the instantiated live stream interface object to acquire the live stream of the live page.
[0102] The live stream decoding module 330 is used to call a decoding method with the height and width corresponding to the decoded live stream as input parameters through the instantiated live stream playback object, decode the live stream, and obtain the decoded live stream.
[0103] The view rendering module 340 is used to call the live stream rendering method with the instantiated interface display object as the entry parameter through the instantiated live stream playback object, and render the decoded live stream to the preset view of the live page.
[0104] The technical solution of the embodiment of the present invention is used to call the preset initialization method encapsulated in the live stream management class through the instantiated object module when detecting that the live page is opened, and instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class. Through the live stream acquisition module, it is used to call the live stream connection method with the address of the live stream as the entry parameter through the instantiated live stream interface object to obtain the live stream of the live page, thereby obtaining the live stream. Through the live stream decoding module, it is used to call the decoding method with the height and width corresponding to the decoded live stream as the entry parameters through the instantiated live stream playback object, decode the live stream, and obtain the decoded live stream.
[0105] Through the view rendering module, it is used to call the live stream rendering method with the instantiated interface display object as the entry parameter through the instantiated live stream playback object, and render the decoded live stream to the preset view of the live page to achieve the playback of the live stream. By calling the preset initialization method encapsulated in the live stream management class when detecting that the live page is opened, the live stream processing efficiency is improved, thereby improving the user experience. By instantiating the pre-defined objects in the live management class, it is possible to apply for memory space for the class corresponding to each object, so that the data and methods in the class can be called, and code decoupling is achieved, thereby achieving a low coupling effect between classes. By calling the live stream connection method with the address of the live stream as the entry parameter, and by calling the decoding method with the height and width corresponding to the decoded live stream as the entry parameter, the reusability of the code is achieved.
[0106] Optionally, before the live stream acquisition module 320, it includes: a live stream address acquisition module 350, which is used to send an address request of the live stream to the server so that the server can feedback the address of the live stream; by calling the parameter content judgment method, it is determined whether the content corresponding to the address of the live stream is empty; if not, the address of the live stream fed back by the server is received.
[0107] Optionally, the live stream address acquisition module 350 is used to call the live stream connection method with the address of the live stream as the entry parameter through the instantiated live interface object, and determine whether the live stream connection method is successfully connected; if so, the live stream of the live page is acquired.
[0108] Optionally, the object instantiation module 310 is used to initialize the message passing objects and live stream interface objects pre-defined in the live stream management class to empty based on the initialization statement; obtain the object information of the live page by calling the object information acquisition method of the page; pass the object information of the live page to the initialized message passing object to obtain the message passing object corresponding to the live page; use the message passing object corresponding to the live page as the entry parameter of the live stream interface object instantiation method; and instantiate the initialized live stream interface object by calling the live stream interface object instantiation method.
[0109] Optionally, the object instantiation module 310 is used to pre-create a factory class of a live stream playback object based on the factory design pattern, obtain the factory method of the live stream playback object; and instantiate the live stream playback object by calling the factory method of the live stream playback object.
[0110] Optionally, the instantiated object module 310 is used to obtain the identifier of the live page by calling the page identifier acquisition method of the object information acquisition method of the page; bind the live page identifier to the interface display object, and instantiate the interface display object.
[0111] Optionally, after the view rendering module 340, it also includes: a resource release module, which is used to call the resource release method encapsulated in the live stream management class to release the resources corresponding to the live stream interface object and the live stream playback object when it is detected that the live stream page is closed.
[0112] The above-mentioned device can execute the live streaming management method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the live streaming management method.
[0113] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present invention.
[0114] Embodiment 5
[0115] Figure 4 It is a structural schematic diagram of an electronic device provided in Embodiment 5 of the present invention. Figure 4 A block diagram of an exemplary electronic device 12 suitable for implementing any of the embodiments of the present invention is shown. Figure 4 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention. The device 12 is typically an electronic device that is responsible for processing configuration information.
[0116] like Figure 4 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a memory 28, and a bus 18 connecting the various components (including the memory 28 and the processing unit 16).
[0117] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0118] The electronic device 12 typically includes a variety of computer readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0119] The memory 28 may include computer device readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a read-only optical disk (Compact Disc-Read Only Memory, CD-ROM), a digital video disk (Digital Video Disc-Read Only Memory, DVD-ROM) or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product 40, which has a set of program modules 42, which are configured to perform the functions of various embodiments of the present invention. The program product 40 may be stored in, for example, the memory 28, and such program modules 42 include, but are not limited to, one or more application programs, other program modules, and program data, each of which or some combination may include the implementation of a network environment. The program module 42 generally performs the functions and / or methods in the embodiments described in the present invention.
[0120] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, mouse, camera, etc., and display), may also communicate with one or more devices that enable a user to interact with the electronic device 12, and / or communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. In addition, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN) and / or a public network, such as the Internet) through a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 through a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) devices, tape drives, and data backup storage devices.
[0121] The processor 16 executes various functional applications and data processing by running the program stored in the memory 28, for example, implementing the live streaming management method provided in the above embodiment of the present invention, the method comprising:
[0122] When it is detected that the live page is opened, the preset initialization method encapsulated in the live stream management class is called to instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class; through the instantiated live stream interface object, the live stream connection method with the address of the live stream as the entry parameter is called to obtain the live stream of the live page; through the instantiated live stream playback object, the decoding method with the height and width corresponding to the decoded live stream as the entry parameters is called to decode the live stream and obtain the decoded live stream; through the instantiated live stream playback object, the live stream rendering method with the instantiated interface display object as the entry parameter is called to render the decoded live stream to the preset view of the live page.
[0123] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the live stream management method provided by any embodiment of the present invention.
[0124] Embodiment 6
[0125] Embodiment 6 of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute a live streaming management method when executed by a computer processor.
[0126] The method includes:
[0127] When it is detected that the live page is opened, a preset initialization method encapsulated in the live stream management class is called to instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class;
[0128] By instantiating the live stream interface object, calling the live stream connection method with the address of the live stream as the entry parameter, the live stream of the live page is obtained;
[0129] By calling the instantiated live stream playback object, a decoding method with the height and width corresponding to the decoded live stream as input parameters is used to decode the live stream to obtain the decoded live stream;
[0130] Through the instantiated live stream playback object, the live stream rendering method with the instantiated interface display object as the entry parameter is called to render the decoded live stream to the preset view of the live page.
[0131] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0132] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0133] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0134] Computer program code for performing the operation of embodiments of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0135] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A live streaming management method, characterized in that: include: When it is detected that the live page is opened, a preset initialization method encapsulated in the live stream management class is called to instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class; By instantiating the live stream interface object, calling the live stream connection method with the address of the live stream as the entry parameter, the live stream of the live page is obtained; By calling the decoding method with the height and width corresponding to the decoded live stream as input parameters through the instantiated live stream playback object, the live stream is decoded to obtain the decoded live stream; By using the instantiated live stream playback object, a live stream rendering method with the instantiated interface display object as an entry parameter is called to render the decoded live stream to a preset view of the live page; Instantiating the predefined live stream interface object in the live stream management class, including: Initialize the message transfer object and the live stream interface object predefined in the live stream management class to be empty based on the initialization statement; Obtain the object information of the live broadcast page by calling the object information acquisition method of the page; Passing the object information of the live page to the initialized message passing object to obtain the message passing object corresponding to the live page; The message transfer object corresponding to the live page is used as the entry parameter of the live stream interface object instantiation method; Instantiate the initialized live stream interface object by calling the live stream interface object instantiation method; Wherein, the object is a combination of data and action, and the object information includes object name and object type; Instantiating the predefined live stream playback object in the live stream management class, including: Based on the factory design pattern, a factory class of a live stream playback object is created in advance, and a factory method of the live stream playback object is obtained; Instantiating the live stream playback object by calling the factory method of the live stream playback object; Instantiating the predefined interface display object in the live stream management class, including: Obtain the identifier of the live broadcast page by calling the page identifier acquisition method of the page object information acquisition method; The live broadcast page identifier is bound to the interface display object, and the interface display object is instantiated.
2. The method according to claim 1, characterized in that Before the instantiated live stream interface object is used to call the live stream connection method with the address of the live stream as the entry parameter to obtain the live stream of the live page, it includes: Sending a request for the address of the live stream to the server, so that the server feeds back the address of the live stream; By calling the parameter content judgment method, it is judged whether the content corresponding to the address of the live stream is empty; If not, the address of the live stream fed back by the receiving server is received.
3. The method according to claim 2, characterized in that The instantiated live stream interface object calls a live stream connection method with the address of the live stream as an entry parameter to obtain the live stream of the live page, including: Calling a live stream connection method using the live stream address as an entry parameter through the instantiated live stream interface object, and determining whether the live stream connection method is successfully connected; If so, the live stream of the live page is obtained.
4. The method according to claim 1, after rendering the decoded live stream to a preset view of the live page, further comprises: When it is detected that the live page is closed, the resource release method encapsulated in the live stream management class is called to release the resources corresponding to the live stream interface object and the live stream playback object.
5. A live streaming management device, characterized in that: include: The instantiation object module is used to call the preset initialization method encapsulated in the live stream management class when detecting that the live stream page is opened, and instantiate the pre-defined live stream interface object, live stream playback object and interface display object in the live stream management class; A live stream acquisition module, used to call a live stream connection method with the address of the live stream as an entry parameter through an instantiated live stream interface object, so as to acquire the live stream of the live page; A live stream decoding module is used to call a decoding method with a height and a width corresponding to the decoded live stream as input parameters through an instantiated live stream playback object, decode the live stream, and obtain a decoded live stream; A view rendering module, used to call a live stream rendering method with an instantiated interface display object as an entry parameter through an instantiated live stream playback object, and render the decoded live stream to a preset view of the live page; The instantiated object module is used to initialize the message transfer object and the live stream interface object predefined in the live stream management class to empty based on the initialization statement; The object information of the live page is obtained by calling the object information obtaining method of the page; the object information of the live page is passed to the initialized message passing object to obtain the message passing object corresponding to the live page; The message transfer object corresponding to the live page is used as the entry parameter of the live stream interface object instantiation method; the initialized live stream interface object is instantiated by calling the live stream interface object instantiation method; Wherein, the object is a combination of data and action, and the object information includes object name and object type; The instantiated object module is further used to pre-create a factory class of a live stream playback object based on the factory design pattern, obtain the factory method of the live stream playback object; and instantiate the live stream playback object by calling the factory method of the live stream playback object; The instantiated object module is also used to obtain the identifier of the live page by calling the page identifier acquisition method of the page object information acquisition method; bind the live page identifier to the interface display object, and instantiate the interface display object.
6. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the program is executed by the processor, the processor implements the live stream management method as described in any one of claims 1-4.
7. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute the live stream management method as described in any one of claims 1 to 4 when executed by a computer processor.
Citation Information
Patent Citations
Playing page layering system, specified player expansion method, medium and device
CN107707980A
Multimedia playing device and method
CN108063971A