Search

EP-4020966-B1 - CALLBACK STREAM PROCESSING METHOD AND DEVICE

EP4020966B1EP 4020966 B1EP4020966 B1EP 4020966B1EP-4020966-B1

Inventors

  • CHEN, Tankun
  • WU, Huayang
  • SHEN, Risheng

Dates

Publication Date
20260506
Application Date
20200910

Claims (13)

  1. A callback stream processing method, wherein the method is carried out by an electronic device, wherein an operating system of the electronic device comprises a camera service, wherein the method comprises: detecting (401) a first operation that a user uses a first function of a first application; starting a camera application in response to the first operation; displaying (402) a first interface corresponding to the first function; creating (413) a preview stream and a first callback stream in parallel, wherein the preview stream is a data stream configured to return a preview image collected by the camera to the first application, so that the first application displays the preview image on a screen, wherein the callback stream is a data stream configured to return image data of the preview image collected by the camera to the first application, so that the first application performs processing based on the image data of the preview image collected by the camera, to implement the first function; obtaining (416) first data, wherein the first data is callback stream data corresponding to the first callback stream; setting (419) a callback function; providing (420), by using the callback function, the first data for the first application for processing; and processing (421) the obtained callback stream data to implement the first function, characterized in that the electronic device comprises a parameter matching library, the parameter matching library comprises at least one scenario parameter group corresponding to a callback stream scenario, and the scenario parameter group comprises a package name, an activity name, and a page name of an application; and before the creating a preview stream and a first callback stream in parallel, the method further comprises: obtaining (407) a first scenario parameter group corresponding to the first interface, wherein the first scenario parameter group is used to describe a current scenario and status of the first interface; determining (409) that the first scenario parameter group matches a scenario parameter group in the parameter matching library; determining (410) that the current scenario is the callback stream scenario, and indicating (411) first information to the camera service through a CameraSDK interface, wherein the first information is used to indicate that the current scenario is the callback stream scenario, and to indicate to perform said step of creating (413) the preview stream and the first callback stream in parallel.
  2. The method according to claim 1, wherein the first scenario parameter group comprises a first package name of the first application corresponding to the first interface, wherein after the displaying (402) a first interface corresponding to the first function, the method further comprises: obtaining (403) the first package name of the first application corresponding to the first interface, wherein the first package name is used to uniquely identify the first application; and searching (404) the parameter matching library for a reference scenario parameter group comprising the first package name; and the determining (409) that the first scenario parameter group matches a scenario parameter group in the parameter matching library comprises: determining that the first scenario parameter group matches the reference scenario parameter group.
  3. The method according to claim 1 or 2, wherein the electronic device obtains the at least one scenario parameter group in that the at least one scenario parameter group in the parameter matching library is integrated into a package file of the first application; or the at least one scenario parameter group in the parameter matching library is pushed by a server; or the at least one scenario parameter group in the parameter matching library is obtained by the electronic device through learning.
  4. The method according to any one of claims 1 to 3, wherein the method further comprises: if the first scenario parameter group does not match a scenario parameter group in the parameter matching library, subsequently, when the first application creates the callback stream based on its service logic, storing the first scenario parameter group in the parameter matching library; and determining, next time based on the first scenario parameter group stored in the parameter matching library, that an interface scenario corresponding to the first scenario parameter group is the callback stream scenario.
  5. The method according to any one of claims 1 to 4, wherein after the determining that the first scenario parameter group matches a scenario parameter group in the parameter matching library, the method further comprises: setting, by the camera service, identification information; and the creating a preview stream and a first callback stream in parallel comprises: indicating, by the first application, to start previewing; creating, by the camera service, the preview stream and the first callback stream in parallel based on the identification information; and deleting, by the camera service, the identification information after creating the first callback stream.
  6. The method according to claim 5, wherein the obtaining first data comprises: obtaining, by the camera service, the first data; the setting a callback function comprises: setting, by the first application, the callback function; and the providing, by using the callback function, the first data for the first application for processing comprises: providing, by the camera service by using the callback function, the first data for the first application for processing.
  7. An electronic device (100), comprising: a screen (194), configured to display an interface; one or more processors (110); and a memory (121), wherein the memory stores code, wherein an operating system of the electronic device comprises a camera service, wherein when the code is executed by the electronic device (100), the electronic device performs the following steps: detecting a first operation that a user uses a first function of a first application; starting a camera application in response to the first operation; displaying a first interface corresponding to the first function; creating a preview stream and a first callback stream in parallel, wherein the preview stream is a data stream configured to return a preview image collected by the camera (193) to the first application, so that the first application displays the preview image on the screen (194), wherein the callback stream is a data stream configured to return image data of the preview image collected by the camera to the first application, so that the first application performs processing based on the image data of the preview image collected by the camera (193), to implement the first function; obtaining first data, wherein the first data is callback stream data corresponding to the first callback stream; setting a callback function; providing, by using the callback function, the first data for the first application for processing; and processing the obtained callback stream data to implement the first function, characterized in that the electronic device comprises a parameter matching library, the parameter matching library comprises at least one scenario parameter group corresponding to a callback stream scenario, and the scenario parameter group comprises a package name, an activity name, and a page name of an application; and when the code is executed by the electronic device, the electronic device further performs the following steps: before the creating a preview stream and a first callback stream in parallel, obtaining a first scenario parameter group corresponding to the first interface, wherein the first scenario parameter group is used to describe a current scenario and status of the first interface; determining that the first scenario parameter group matches a scenario parameter group in the parameter matching library; determining that the current scenario is the callback stream scenario, and indicating (411) first information to the camera service through a CameraSDK interface, wherein the first information is used to indicate that the current scenario is the callback stream scenario, and to indicate to perform said step of creating (413) the preview stream and the first callback stream in parallel.
  8. The electronic device (100) according to claim 7, wherein the first scenario parameter group comprises a first package name of the first application corresponding to the first interface, wherein when the code is executed by the electronic device, the electronic device further performs the following steps: after the displaying a first interface corresponding to the first function, obtaining the first package name of the first application corresponding to the first interface, wherein the first package name is used to uniquely identify the first application; and searching the parameter matching library for a reference scenario parameter group comprising the first package name; and the determining that the first scenario parameter group matches a scenario parameter group in the parameter matching library comprises: determining that the first scenario parameter group matches the reference scenario parameter group.
  9. The electronic device (100) according to claim 7 or 8, wherein the electronic device obtains the at least one scenario parameter group in that the at least one scenario parameter group in the parameter matching library is integrated into a package file of the first application; the at least one scenario parameter group in the parameter matching library is pushed by a server; and the at least one scenario parameter group in the parameter matching library is obtained by the electronic device through learning.
  10. The electronic device (100) according to any one of claims 7 to 9, wherein when the code is executed by the electronic device, the electronic device further performs the following steps: if the first scenario parameter group does not match a scenario parameter group in the parameter matching library, subsequently, when the first application creates the callback stream based on its service logic, storing the first scenario parameter group in the parameter matching library; and determining, next time based on the first scenario parameter group stored in the parameter matching library, that an interface scenario corresponding to the first scenario parameter group is the callback stream scenario.
  11. The electronic device (100) according to any one of claims 7 to 10, wherein when the code is executed by the electronic device, the electronic device further performs the following step: after the determining that the first scenario parameter group matches a scenario parameter group in the parameter matching library, setting, by the camera service, identification information; and the creating a preview stream and a first callback stream in parallel specifically comprises: indicating, by the first application, to start previewing; creating, by the camera service, the preview stream and the first callback stream in parallel based on the identification information; and deleting, by the camera service, the identification information after creating the first callback stream.
  12. The electronic device (100) according to claim 11, wherein the obtaining first data specifically comprises: obtaining, by the camera service, the first data; the setting a callback function specifically comprises: setting, by the first application, the callback function; and the providing, by using the callback function, the first data for the first application for processing specifically comprises: providing, by the camera service by using the callback function, the first data for the first application for processing.
  13. A computer storage medium, wherein the computer storage medium comprises computer instructions, and when the computer instructions are run on an electronic device, the electronic device performs the callback stream processing method according to any one of claims 1 to 6.

Description

TECHNICAL FIELD Embodiments of this application relate to the field of electronic technologies, and in particular, to a callback stream processing method and a device. BACKGROUND Currently, a camera function is added to an increasing quantity of applications (application, app) on an electronic device. For example, an app may use a camera to perform processing such as photographing, code scanning, video chatting, or augmented reality (augmented reality, AR). A user uses the camera by using the app more frequently. Scenarios in which an app uses a camera function generally include a preview stream (preview Stream) of a camera, and some scenarios also include a callback stream (callbackStream). For example, a scenario such as code scanning, video chatting, or AR includes a callback stream, which may be referred to as a callback stream scenario. In the conventional technology, for the callback stream scenario, refer to FIG. 1A. An app may invoke an openCamera() interface to start a camera, and then the app may invoke a startPreview() interface to start previewing. After the previewing is started, a hardware abstraction layer (hardware abstraction layer, HAL) in an electronic device may create a preview stream. Then, the app may perform initialization processing such as autofocusing. Subsequently, the app may set a callback function. After the callback function is set, the HAL layer may first stop the previous preview stream, create a new preview stream, and create a callback stream after the new preview stream is successfully created. Then, after the callback stream is successfully created, the app obtains callback stream data by using the callback function, and performs processing based on the callback stream data. In the solution shown in FIG. 1A, when a user invokes the camera by using the app, the app needs a relatively long time to obtain the callback stream data, and then can perform processing based on the callback stream data. Consequently, app processing is relatively time-consuming, and user experience is relatively poor. CN 107 360 400 A discloses a video recording method for a camera of an intelligent device. The video recording method includes the steps of carrying out video recording on a first camera of the intelligent device and storing as first video recording data, and starting a second camera of the intelligent device and obtaining and storing second preview picture data of the second camera; displaying a current picture of the first camera which carries out video recording currently in a display area of the intelligent device; and after a switching command is received, switching to the second camera to carry out video recording and storing as video recording data, and synthesizing the first video recording data and the second preview picture data. SUMMARY Embodiments of the present invention are defined by the independent claims. Additional features of embodiments of the invention are presented in the dependent claims. In the following, parts of the description and drawings referring to former embodiments which do not necessarily comprise all features to implement embodiments of the claimed invention are not represented as embodiments of the invention but as examples useful for understanding the embodiments of the invention. Embodiments of this application provide a callback stream processing method and a device. In a callback stream scenario, an electronic device may set a preview stream and a callback stream in parallel, to start the callback stream in advance and obtain callback stream data. After an application sets a callback function, the electronic device may directly return, by using the callback function, the callback stream data to the application for processing. This can shorten a time consumed by the electronic device for creating a preview stream and a callback stream, shorten a time consumed by the application for obtaining callback stream data, shorten a processing time of the application and a user waiting time, and improve user experience. To achieve the foregoing objectives, the following technical solutions are used in the embodiments of this application. According to one aspect, an embodiment of this application provides a callback stream processing method. The method is applied to an electronic device, wherein an operating system of the electronic device includes a camera service, and includes: The electronic device detects a first operation that a user uses a first function of a first application. In response to the first operation, the electronic device starts a camera application, and displays a first interface corresponding to the first function. Then, the electronic device creates a preview stream and a first callback stream in parallel. Subsequently, the electronic device obtains first data. The first data is callback stream data corresponding to the first callback stream. The electronic device sets a callback function, and provides, by using the callback function,