WO2022156484A1 - Media data processing method and apparatus, and terminal device - Google Patents

Media data processing method and apparatus, and terminal device Download PDF

Info

Publication number
WO2022156484A1
WO2022156484A1 PCT/CN2021/141323 CN2021141323W WO2022156484A1 WO 2022156484 A1 WO2022156484 A1 WO 2022156484A1 CN 2021141323 W CN2021141323 W CN 2021141323W WO 2022156484 A1 WO2022156484 A1 WO 2022156484A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
target file
media
attribute information
target
Prior art date
Application number
PCT/CN2021/141323
Other languages
French (fr)
Chinese (zh)
Inventor
彭应康
王朕元
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022156484A1 publication Critical patent/WO2022156484A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/54Browsing; Visualisation therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/40Information retrieval; Database structures therefor; File system structures therefor of multimedia data, e.g. slideshows comprising image and additional audio data
    • G06F16/41Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/40Information retrieval; Database structures therefor; File system structures therefor of multimedia data, e.g. slideshows comprising image and additional audio data
    • G06F16/44Browsing; Visualisation therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/51Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/60Information retrieval; Database structures therefor; File system structures therefor of audio data
    • G06F16/61Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/60Information retrieval; Database structures therefor; File system structures therefor of audio data
    • G06F16/64Browsing; Visualisation therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/70Information retrieval; Database structures therefor; File system structures therefor of video data
    • G06F16/71Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/70Information retrieval; Database structures therefor; File system structures therefor of video data
    • G06F16/74Browsing; Visualisation therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/56Computer malware detection or handling, e.g. anti-virus arrangements

Definitions

  • the present application relates to the technical field of data processing, and in particular, to a method, apparatus and terminal device for processing media data.
  • the media file when a user adds a media file such as a picture or video through some APP installed in the smartphone, the media file will be stored in the memory, and the attribute information of the media file (such as file name, file size, storage path, etc.).
  • the media file when a user deletes a media file in the smartphone through some APPs, the media file will be deleted from the memory, and the attribute information of the media file in the media database will also be deleted.
  • the media files stored in the memory can be displayed to the user through the gallery or photo album APP in the smart phone based on the attribute information of the media files stored in the media database.
  • the media database is not refreshed in time.
  • the smartphone may need to be restarted to scan and refresh, so that the smartphone cannot display the newly added media files to the user in time, or The deleted files are still displayed to the user, so the user experience is poor.
  • the present application provides a media data processing method, device and terminal device, which solve the problem in the prior art that the media file information in the media database cannot be refreshed in real time when accessing and processing media files through an APP.
  • the present application provides a method for processing media data, the method comprising: when receiving a processing request for a target file sent by a first application, calling a first interface of a file system of a terminal device, and according to the processing request instructed The processing method processes the target file; if the target file is a media type file, execute file scanning to obtain the scanning result corresponding to the target file; update the attribute of the target file in the media database of the terminal device according to the scanning result corresponding to the target file information.
  • the interface of the file system can be called to process the target file according to the processing method indicated by the processing request, and determine Whether the changed file is a media file, if it is a media file, trigger file scanning to synchronize the media file information in the media database with the actual media file in real time to ensure the consistency and integrity of the media file information.
  • the gallery can quickly display the stored images for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
  • the above-mentioned file system may include multiple interfaces, such as adding interface, deleting interface, modifying interface, and viewing interface, which are respectively used to perform operations such as adding a file, deleting a file, modifying a file, and viewing a file.
  • the terminal device can perform operations such as adding, deleting, modifying or viewing files through the corresponding interface of the file system.
  • the above-mentioned media database may also be referred to as a multimedia database or a media storage database, and is used to store relevant attribute information of media files, which can be called by an APP to realize access to media files.
  • the media database may include relevant attribute information of each media file, for example, may include file attribute information such as storage path information, file name information, file type information, file size information, and/or last modification time information of the media file; or may include any other Possible attribute information such as category tags, favorites, and/or privacy.
  • the attribute information of the target file includes at least one of the following: storage path information of the target file, name information of the target file, file size information of the target file, file type information of the target file, Last modified time information.
  • the files of the above media types may be image files, such as pictures or photos, video files, or audio files, or any other possible files.
  • the method before performing file scanning if the target file is a media type file, the method further includes: calling a second interface of the file system to determine whether the target file is a media type file.
  • the terminal device may determine the file type according to the suffix of the file name, so as to determine whether the target file is a media type file.
  • other methods can also be used to determine whether the target file is a media file. For example, by parsing the file header information, it can be checked whether the file header information contains a field indicating the media type. If it contains a field indicating the media type, it is determined that the target file is a media file. document.
  • the file system reports to the media scanning service that the target file is a media file, to trigger file scanning, and then update the attribute of the target file in the media database according to the scanning result. information.
  • the present application can realize the synchronization of the media database and the actual file based on the file system reporting mechanism.
  • an interface for judging whether the target file is a media file is added to the file system, that is, through the interface of the file system, not only the processing method (such as adding, deleting or Modify) to process the target file, and it can also judge whether the file requested to be processed is a media type file.
  • the first interface and the second interface may be the same application programming interface.
  • the interface not only has the ability to process the target file according to the processing method indicated by the processing request, but also has the ability to determine whether the target file is a media ability to type files.
  • the first interface and the second interface may be two independent application programming interfaces respectively, the first interface has the ability to process the target file according to the processing method indicated by the processing request, and the second interface has the ability to determine whether the target file is a The capability of the file of the media type. Whether the first interface and the second interface are the same interface can be specifically determined according to the actual usage, which is not limited in this embodiment of the present application.
  • the method before performing the file scanning, further includes: reporting a first message to the media file scanning service via a daemon process of the file system, where the first message is used to instruct the file scanning to be performed.
  • the above-mentioned execution of file scanning includes: according to the first message, starting a media file scanning service process to execute media file scanning.
  • the information interaction between the file system and the media file scanning service can be realized, and the media file scanning service can be triggered to perform file scanning when the file system processes the media files.
  • the first interface of the file system of the terminal device is called to process the target file according to the processing method indicated by the processing request, including: :
  • the delete interface of the file system is called to delete the target file stored in the memory
  • the modification interface of the file system is invoked, the target file is modified, and the target file stored in the memory is updated to the modified target file.
  • the above-mentioned modification target file may be the storage path of the modification file, the content of the modification file, the name of the modification file, or the modification of the file in any other possible manner.
  • the above-mentioned memory may be an internal memory of the terminal device, or may be an external memory (eg, a pluggable SD card), which may be specifically determined according to actual usage requirements, which is not limited in the embodiments of the present application.
  • an external memory eg, a pluggable SD card
  • the file requested to be processed is a media file
  • the attribute information of the target file is updated in the media database of the terminal device, including:
  • the scan result corresponding to the target file is that the target file is newly added to the storage of the terminal device, and the attribute information of the target file does not exist in the media database, the attribute information of the target file is acquired, and the attribute information of the target file is added to the media database.
  • attribute information
  • the scanning result corresponding to the target file is that the target file in the memory is deleted, and the attribute information of the target file exists in the media database, then delete the attribute information of the target file in the media database;
  • the scan result corresponding to the target file is that the target file in the memory is modified and the attribute information of the target file before the modification exists in the media database, then the attribute information of the modified target file is obtained, and the pre-modification information in the media database is obtained.
  • the attribute information of the target file is replaced with the attribute information of the modified target file.
  • the media database can be updated according to the scan result, and the media file information in the media database can be synchronized with the actual media file in real time.
  • the media file attribute information in the media database is synchronized with the actual media file in real time, ensuring the consistency of the media file information in the terminal device and improving the user experience.
  • obtaining the attribute information of the target file above includes: parsing the newly added target file through a file parsing service process to obtain the attribute information of the target file.
  • obtaining the attribute information of the modified target file includes: parsing the modified target file through a file parsing service process to obtain the attribute information of the modified target file.
  • the terminal device may also be configured with a file display application associated with the media database.
  • the file display application can display the thumbnail of the file according to the attribute information of the file in the media database, that is, the file display application relies on the file attribute information recorded in the media database when displaying images.
  • the above method further includes: updating the attribute information of the target file in the file display application of the terminal device according to the updated attribute information of the target file in the media database. Display state.
  • the above-mentioned updating the display state of the target file in the file display application of the terminal device according to the updated attribute information of the target file in the media database includes:
  • the thumbnail corresponding to the target file is newly displayed in the file display application
  • the thumbnail image corresponding to the target file is canceled in the file display application
  • the thumbnail image corresponding to the target file is updated and displayed in the file display application.
  • the file display application can update the thumbnail of the displayed file in real time according to the updated attribute information of the file in the media database. Thumbnails, so that when the user browses images through the file display application, each image stored in the terminal device can be displayed quickly and in real time for the user, avoiding the terminal device being unable to display the newly added media files to the user in time or files that have been deleted. The problem is still being presented to the user, improving the user experience.
  • the present application provides an apparatus for processing media data, the apparatus including a unit for executing the method in the above-mentioned first aspect.
  • the apparatus may correspond to executing the method described in the first aspect.
  • the description of the units in the apparatus please refer to the description of the first aspect. For brevity, details are not repeated here.
  • the method described in the first aspect above may be implemented by hardware, or may be implemented by executing corresponding software by hardware.
  • the hardware or software includes one or more modules or units corresponding to the above functions. For example, a processing module or unit, a display module or unit, and the like.
  • the present application provides a terminal device, the terminal device includes a processor, the processor is coupled with a memory, the memory is used for storing computer programs or instructions, and the processor is used for executing the computer programs or instructions stored in the memory, so that the first aspect The method in is executed.
  • the processor is configured to execute a computer program or instructions stored in the memory to cause the apparatus to perform the method of the first aspect.
  • the present application provides a computer-readable storage medium on which a computer program (which may also be referred to as instructions or codes) for implementing the method in the first aspect is stored.
  • the computer program when executed by a computer, causes the computer to perform the method of the first aspect.
  • the present application provides a chip including a processor.
  • the processor is adapted to read and execute the computer program stored in the memory to perform the method of the first aspect and any possible implementations thereof.
  • the above-mentioned chip further includes a memory, and the memory is connected to the processor through a circuit or a wire.
  • the present application provides a chip system including a processor.
  • the processor is adapted to read and execute the computer program stored in the memory to perform the method of the first aspect and any possible implementations thereof.
  • the chip system further includes a memory, and the memory is connected to the processor through a circuit or a wire.
  • the present application provides a computer program product, the computer program product comprising a computer program (also referred to as instructions or codes), which when executed by a computer causes the computer to implement the method in the first aspect.
  • a computer program also referred to as instructions or codes
  • FIG. 1 is a system architecture diagram of the interaction between the APP and the media database when processing media files through the APP in the related art.
  • FIG. 2 is a schematic structural diagram of an operating system to which the media data processing method provided by the embodiment of the present application is applied.
  • FIG. 3 is a schematic flowchart of a media data processing method provided by an embodiment of the present application.
  • FIG. 4 is a system architecture diagram of interaction between an APP and a media database when processing a media file through an APP according to an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of another media data processing method provided by an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a media data processing apparatus provided by an embodiment of the present application.
  • FIG. 7 is a schematic hardware diagram of a terminal device according to an embodiment of the present application.
  • first and second and the like in the specification and claims herein are used to distinguish between different objects, rather than to describe a particular order of the objects.
  • first interface, the second interface, etc. are used to distinguish different interfaces, rather than to describe a specific order of the interfaces.
  • words such as “exemplary” or “for example” are used to represent examples, illustrations or illustrations. Any embodiments or designs described in the embodiments of the present application as “exemplary” or “such as” should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as “exemplary” or “such as” is intended to present the related concepts in a specific manner.
  • plural refers to two or more, for example, a plurality of processing units refers to two or more processing units, etc.; a plurality of An element refers to two or more elements or the like.
  • a terminal device such as a mobile phone is usually equipped with a memory, which can store various image files such as pictures and videos.
  • the memory can be the built-in memory of the terminal device, or it can be a pluggable memory card (secure digital card, SD).
  • the media database (data base, DB) in the mobile phone can record file attribute information such as the storage path, file name, and file size of each image file in the memory.
  • File display software is usually preset or installed on the mobile phone, such as the pre-made gallery or photo album APP in the mobile phone (which can be attributed to the system APP), or the third-party APP installed in the mobile phone. This kind of image management APP can display pictures and videos. image file.
  • the media scanning service of the mobile phone system is responsible for scanning the files stored in the memory, and storing the relevant information of the files in the memory in the media database for the image management APP in the mobile phone (for example, the pre-made system APP in the mobile phone or the installation in the mobile phone).
  • the image management APP in the mobile phone for example, the pre-made system APP in the mobile phone or the installation in the mobile phone.
  • third-party APP third-party APP
  • the image management APP when the user starts the image management APP to browse images, the image management APP first calls the image file information recorded in the media database, and then calls the image file stored in the memory card through the image file information recorded in the media database. , so as to display the corresponding image and realize image browsing.
  • the media database After scanning the files stored in the memory, the media database will update the file information accordingly.
  • the APP sends a broadcast.
  • the APP will actively send a broadcast to notify the media scanning service of the mobile phone system to scan to update the media database.
  • the mobile phone system is restarted.
  • the media scanning service will be triggered to scan all the directories in the mobile phone recursively, and store the relevant information of each media file in the media database.
  • SD card is inserted and unplugged.
  • the phone SD card mount
  • it will trigger to scan the files in the SD card.
  • the above-mentioned situations 2 and 3 are relatively rarely used in practical applications, and the above-mentioned situation 1 is relatively used in practical applications.
  • the following exemplarily illustrates a schematic diagram of the interaction between the APP and the media database when the APP processes media files in the related art with reference to FIG. 1 .
  • Media Scanner Receiver corresponding to MediaScannerReceiver in the Android operating system
  • the Intent event may also be the boot completion notification issued by the operating system, which triggers a full disk scan; it may also be the SD card mounting completion notification issued by the operating system, which triggers the SD card scan; for the sake of simplicity and clarity, Figure 1 is not shown.
  • the "Media Scanner Service” (corresponding to the MediaScannerService in the Android system) can realize the instantiation of the “Media Scanner” (corresponding to the MediaScanner in the Android operating system) and the update of the media database based on the broadcast sent by the APP.
  • “Media Provider” (corresponding to MediaProvider in the Android operating system) is used as the encapsulation class of the media database, which is used to create and maintain the database, and provide a uniform resource identifier (URI) externally to realize the addition of the database.
  • URI uniform resource identifier
  • delete, modify or query (referred to as CRUD) function.
  • the APP can call the interface of "media provision” through "content resolution” (corresponding to ContentResolver in the Android operating system) , to add, delete, modify, and query the database data in "Media Provision".
  • the file information recorded in the media database will be inconsistent or out of sync with the actual files stored in the memory, which may eventually lead to various problems, such as slow refresh of the gallery, pictures that cannot be displayed for a long time, and mobile phones.
  • the newly added media files may not be displayed to the user in time, or the deleted files may still be displayed to the user.
  • the media database cannot be updated by scanning until the mobile phone system is restarted; in this case, since not only all directories in the mobile phone are scanned, but also unsynchronized files need to be parsed, which will greatly increase the number of mobile phones.
  • the burden after rebooting In view of this, how to keep the media database and the actual file consistent in real time is a technical problem to be solved by the embodiments of the present application.
  • Embodiments of the present application provide a media data processing method and a terminal device, which can realize synchronization between a media database and an actual file based on file system reporting. Specifically, when a processing request for the target file sent by the first application is received, the first interface of the file system of the terminal device is called to process the target file according to the processing method indicated by the processing request; if the target file is a media type file, perform file scanning to obtain the scanning result corresponding to the target file; update the attribute information of the target file in the media database of the terminal device according to the scanning result corresponding to the target file.
  • the interface of the file system is called to process the target file according to the processing method indicated by the processing request, and it is judged that the occurrence of Whether the changed file is a media file, if it is a media file, trigger file scanning to synchronize the media file information in the media database with the actual media file in real time to ensure the consistency and integrity of the media file information.
  • the gallery can quickly display the stored images for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
  • the embodiments of the present application trigger file scanning through a file system reporting mechanism, so as to synchronize media file information in the media database with actual media files in real time, ensure the consistency and integrity of media file information, and improve user experience.
  • the terminal device in this embodiment of the present application may be a terminal device having an operating system.
  • the operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, which are not specifically limited in the embodiments of the present application.
  • the following takes the Android operating system as an example to introduce the software environment to which the media data processing method provided by the embodiment of the present application is applied.
  • FIG. 2 it is a schematic diagram of the architecture of a possible Android operating system provided by an embodiment of the present application.
  • the architecture of the Android operating system includes four layers, namely: an application layer, an application framework layer, a system runtime layer, and a kernel layer (specifically, a Linux kernel layer).
  • the application layer includes various applications (including system applications and third-party applications) in the Android operating system.
  • the application framework layer is the framework of the application, and developers can develop some applications based on the application framework layer under the condition of complying with the development principles of the framework of the application.
  • the system runtime layer includes libraries (also called system libraries) and the Android operating system runtime environment.
  • the library mainly provides various resources required by the Android operating system.
  • the Android operating system operating environment is used to provide a software environment for the Android operating system.
  • the kernel layer is the operating system layer of the Android operating system and belongs to the bottom layer of the Android operating system software layer.
  • the kernel layer provides core system services and hardware-related drivers for the Android operating system based on the Linux kernel.
  • a developer can develop a software program for implementing the media data processing method provided by the embodiment of the present application based on the system architecture of the Android operating system as shown in FIG.
  • the media data processing method can run based on the Android operating system as shown in FIG. 2 . That is, the processor or the terminal device can implement the media data processing method provided by the embodiments of the present application by running the software program in the Android operating system.
  • the terminal device in this embodiment of the present application may be a mobile terminal or a non-mobile terminal.
  • the mobile terminal may be a mobile phone, a tablet computer, a notebook computer, a palmtop computer, a vehicle-mounted terminal, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (personal digital assistant, PDA), etc.
  • the non-mobile terminal may be a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which are not specifically limited in the embodiments of the present application.
  • the execution subject of the media data processing method provided by the embodiment of the present application may be the above-mentioned terminal device, or may be a functional module and/or functional entity in the terminal device capable of implementing the media data processing method, and the specific implementation may be based on actual usage requirements. It is confirmed that the embodiments of the present application are not limited.
  • the media data processing method provided by the embodiment of the present application is exemplarily described below by taking a terminal device as an example and with reference to the accompanying drawings.
  • the media data processing method is applied to a terminal device.
  • the terminal device is preset with a system APP and installed with a third-party APP.
  • the system APP and the third-party APP are collectively referred to as the first application.
  • the terminal device is configured with a file system and a media database associated with the first application.
  • the file system is used to perform operations for adding, deleting, modifying and viewing files.
  • the database is used to store the relevant information of the media file for the first application to call, so as to display the media file for the user. Referring to FIG. 3 , the method 100 includes the following steps S110-S140.
  • the terminal device When receiving the processing request for the target file sent by the first application, invokes the first interface of the file system to process the target file according to the processing method indicated by the processing request.
  • the file system is a collection of software and managed files and data structures (such as directories and index tables) that manage computer software resources in the form of files in the operating system, which can be used to perform addition, deletion, modification or modification of files. View and other operations. From the system point of view, the file system organizes, allocates and reclaims the storage space of the file storage, and is responsible for the storage, retrieval, sharing and protection of files. From the user's point of view, the information in the file can be accessed according to the file name of the desired file, that is, "access by name".
  • data structures such as directories and index tables
  • the file system may include multiple interfaces, such as an add interface, a delete interface, a modification interface, and a view interface, which are respectively used to perform operations such as adding a file, deleting a file, modifying a file, and viewing a file.
  • the terminal device can perform operations such as adding, deleting, modifying or viewing files through the corresponding interface of the file system.
  • the foregoing S110 may specifically include the following three possible implementation manners:
  • the terminal device calls the new interface of the file system to store the target file in the memory of the terminal device.
  • the above-mentioned newly added target file may be a picture or video file obtained by taking a camera, or may be a picture or a video file downloaded from the network, or an audio file may be downloaded from the network, or added in any other possible way.
  • the file can be specifically determined according to actual use requirements, which is not limited in the embodiment of the present application.
  • the terminal device calls the delete interface of the file system to delete the target file stored in the memory.
  • the above-mentioned modification target file may be the storage path of the modification file, the content of the modification file, the name of the modification file, or the modification of the file in any other possible way, which can be determined according to actual use requirements.
  • the embodiments of the present application are not limited.
  • the memory of the terminal device may be an internal memory or an external memory (for example, a pluggable SD card), which may be specifically determined according to actual usage requirements, which is not limited in this embodiment of the present application.
  • the terminal device invokes the second interface of the file system to determine whether the target file is a file of a media type.
  • This embodiment of the present application adds an interface for determining whether a target file is a media file in the file system, that is, through the interface of the file system, not only can the target file be processed according to the processing method (such as adding, deleting or modifying) indicated by the processing request processing, and it can also be judged whether the file requested to be processed is a media type file (may be referred to as a media file for short).
  • the processing method such as adding, deleting or modifying
  • first interface and the second interface may be the same application programming interface.
  • the interface not only has the ability to process the target file according to the processing method indicated by the processing request, but also has the ability to judge the target file. Whether the file is capable of media type.
  • the first interface and the second interface may be two independent application programming interfaces respectively, the first interface has the ability to process the target file according to the processing method indicated by the processing request, and the second interface has the ability to determine whether the target file is a The capability of the file of the media type. Whether the first interface and the second interface are the same interface can be specifically determined according to the actual usage, which is not limited in this embodiment of the present application.
  • the embodiment of the present application may also use other possible methods to determine whether the target file is a media file.
  • the file system may notify the media file scanning service of the event that the target file is processed, and the media file scanning service first determines the target file. Whether the file is a media file, and then determine whether to perform file scanning according to the judgment result. Specifically, if the target file is a media file, file scanning is performed; if the target file is not a media file, file scanning is not performed. Specifically, it can be determined according to actual use requirements, which is not limited in the embodiment of the present application.
  • the files of the above-mentioned media types may be image files, such as pictures or photos, may also be video files, or audio files, or may be any other possible files.
  • image files such as pictures or photos
  • video files or audio files
  • the requirements are determined, which is not limited in the embodiments of the present application.
  • the terminal device may determine the file type according to the suffix of the file name to determine whether the target file is a media type file.
  • common image file name suffixes may include .BMP, .GIF, .JPEG, .PSD, or .PNG.
  • Common audio file name suffixes can include .WAV, .MP1, .MP2, .MP3, or .MP4.
  • Common video file name suffixes can include .GIF, .AVI, .MOV, .MPEG, or .RM.
  • other methods can also be used to determine whether the target file is a media file. For example, by parsing the file header information, it is possible to check whether the file header information contains a field indicating the media type. If it contains a field indicating the media type, the target file is determined to be a media file. document.
  • the terminal device determines that the target file is a media file, the terminal device continues to perform the following S130. If the terminal device determines that the target file is not a media file, the terminal device ends the operation.
  • the terminal device performs file scanning to obtain a scanning result corresponding to the target file.
  • the File scanning which in turn can update the media database based on the scan results.
  • the file scanning process is exemplarily described below.
  • a background thread can be started to perform the file scanning action.
  • the scanning start broadcast will be sent, and the scanning completion broadcast will be sent after the scanning is completed.
  • a pre-scan action can be performed to traverse each piece of data (ie, file attribute information) in the media database to check whether the actual file corresponding to each piece of data exists in the memory.
  • the terminal device traverses and scans each folder on the internal/external memory one by one (referred to as memory scanning), and when a target file is scanned, it queries the media database for relevant attribute information of the target file.
  • Result 1 The target file is added to the storage and the attribute information of the target file does not exist in the media database.
  • Result 2 The target file in the storage is deleted and the attribute information of the target file exists in the media database.
  • Result three The target file in the storage is modified and the attribute information of the target file exists in the media database.
  • the media database can be updated according to the scan result, so as to synchronize the media file information in the media database with the actual media file in real time.
  • the terminal device updates the attribute information of the target file in the media database according to the scanning result corresponding to the target file.
  • the above-mentioned media database may also be referred to as a multimedia database or a media storage database, and is used to store relevant attribute information of media files, which can be invoked by an APP to realize access to media files.
  • the media database may include relevant attribute information of each media file, for example, may include file attribute information such as storage path information, file name information, file type information, file size information and/or last modification time information of the media file; or Any other possible attribute information may be included, such as category tags, favorites, and/or privacy.
  • file attribute information such as storage path information, file name information, file type information, file size information and/or last modification time information of the media file; or Any other possible attribute information may be included, such as category tags, favorites, and/or privacy.
  • the attribute information of the media file may be specifically determined according to actual usage requirements, which is not limited in this embodiment of the present application.
  • the file system reports to the media scanning service process that the target file is a media file, so as to trigger the execution of file scanning, and then according to the scanning result, in the media database
  • the attribute information of the target file is updated in the file system, that is, the synchronization between the media database and the actual file is realized based on the file system reporting mechanism.
  • the terminal device may report messages to the media file scanning service via the daemon process of the file system. In this way, the information interaction between the file system and the media file scanning service is realized, and when the file system processes the media files, the media file scanning service can be triggered to perform file scanning.
  • the foregoing S140 may specifically include the following three possible implementation manners:
  • the terminal device obtains the attribute information of the target file, and adds the target file in the media database. Attribute information for the file.
  • the terminal device starts the media file scanning service process to scan, finds the target file, and queries whether the relevant attribute information of the target file exists in the media database, and if not, starts the file parsing service process to parse the target file, and obtains Attribute information of the target file. Further, the attribute information of the obtained target file is added to the media database.
  • adding a file through a third-party APP will eventually trigger a call to a new interface of the file system.
  • the newly added interface of the file system can not only add the newly added file to the storage of the terminal device, but also can judge whether the newly added file is a media file. If it is determined that the newly added file is a media file, the message of the newly added file is reported to the daemon process of the file system, and the message of the newly added file is reported to the "media file scanning service" through the daemon process.
  • the "media file scanning service” calls the “file parsing service” to parse the newly added file. Then, the "file parsing service” adds the file-related attribute information obtained by parsing the file into the media database.
  • the terminal device can read all file information in the media database, then check whether each file still exists in the memory, and delete the relevant attribute information of the file from the media database for the file that does not exist in the memory. Specifically, if the target file has been deleted from the storage, the relevant attribute information of the target file is deleted from the media database.
  • deleting a file through a third-party APP will eventually trigger calling a delete interface of the file system.
  • the deletion interface of the file system can not only delete the specified file from the storage of the terminal device, but also judge whether the deleted file is a media file. If it is determined that the deleted file is a media file, the file deletion message is reported to the daemon process of the file system, and the file deletion message is reported to the "media file scanning service" through the daemon process. "Media file scanning service" finds the relevant attribute information of deleted files by scanning the media database. Then, the relevant attribute information of the deleted file is deleted from the media database.
  • Mode 3 If the scan result corresponding to the target file is that the target file in the memory is modified and the attribute information of the target file before the modification exists in the media database, the terminal device obtains the attribute information of the modified target file, and uses the media database to obtain the attribute information of the modified target file. Replace the attribute information of the target file before modification with the attribute information of the modified target file.
  • the terminal device can start the media file scanning service process to scan, find the modified target file, and query whether the relevant attribute information of the target file exists in the media database, and if so, compare the modification time of the actual media file with the media Check whether the modification time of the database is consistent; if it is inconsistent, it means that it has not been updated after modification, then start the file parsing service process to parse the modified target file, and obtain the attribute information of the modified target file (that is, the latest file attribute information). Further, the file attribute information in the media database is replaced with the latest file attribute information, thereby realizing real-time update of the media database.
  • modifying a file through a third-party APP will eventually trigger calling a modification interface of the file system.
  • the modification interface of the file system can not only replace the corresponding file in the storage with the modified file, but also can judge whether the modified file is a media file. If it is determined that the modified file is a media file, the file modified message is reported to the daemon process of the file system, and the file modified message is reported to the "media file scanning service" through the daemon process.
  • the "media file scanning service” calls the “file parsing service” to parse the modified file. Then, the "file parsing service” updates the file-related attribute information obtained by parsing the file into the media database.
  • the terminal device may send a processing request for the target file to the file system in response to the user's operation of adding, deleting, modifying, and checking the target file through the third-party APP.
  • the file system processes the target file according to the processing method indicated by the processing request; on the other hand, the file system calls the corresponding interface to determine whether the target file is a media file according to the processing request.
  • the target file is a media type file
  • a message is reported to the "Media File Scanning Service” via the "file daemon” (vold) of the file system, instructing to perform file scanning.
  • trigger the media file scanning service process to start, perform file scanning and file analysis, obtain the scanning result corresponding to the target file, and call "media provision”, and update the attribute of the target file in the media database according to the scanning result corresponding to the target file information.
  • the embodiment of the present application triggers file scanning through the file system reporting mechanism, so as to synchronize the media file information in the media database with the actual media file in real time, and ensure the consistency of the media file information in the terminal device.
  • the media file attribute information in the media database can be synchronized with the actual media file in real time, ensuring the consistency of media file information and improving user experience.
  • the terminal device is used as the execution subject for exemplary description, and in actual implementation, the execution subject may specifically be a central processing unit (central processing unit, CPU) in the terminal device.
  • CPU central processing unit
  • the CPU in the terminal device receives the processing request for the target file sent by the first application, the CPU calls the first interface of the file system to process the target file according to the processing method indicated by the processing request; then, The CPU invokes the second interface of the file system to determine whether the target file is a media type file; further, if the target file is a media type file, execute file scanning to obtain a scan result corresponding to the target file; The attribute information of the target file is updated in the media database corresponding to the scanning result.
  • CPU central processing unit
  • the first application is an application in the terminal device as an example for description. It can be understood that the embodiment of the present application is not limited to this, for example, the above first application may also be other terminals
  • An application in a device, in this case, the terminal device and other terminal devices may be two devices that establish mutual trust authorization, one of which is the master device and the other is the controlled device.
  • the first application of the master control device can operate the media file, trigger the controlled device to perform the operation of adding, deleting, modifying and checking the media file and the updating operation of the media database, so as to realize the attribute information of the media file in the media database. Real-time synchronization with actual media files. Specifically, it can be determined according to the actual use situation, which is not limited in the embodiment of the present application.
  • the first interface of the file system of the terminal device is invoked, and the target file is processed according to the processing method indicated by the processing request. ; If the target file is a media type file, perform file scanning to obtain the scanning result corresponding to the target file; update the attribute information of the target file in the media database of the terminal device according to the scanning result corresponding to the target file.
  • an interface for judging whether the target file is a media file is added to the file system.
  • the file system can The interface processes the target file according to the processing method indicated by the processing request, and judges whether the changed file is a media file. Synchronization ensures the consistency and integrity of media file information.
  • the terminal device may also be configured with a file display APP associated with the media database.
  • the file display APP can display the thumbnail of the file according to the attribute information of the file in the media database, that is, the file display APP relies on the file attribute information recorded in the media database when displaying the image.
  • the attribute information of the file in the media database needs to be updated synchronously, and the file display APP can update the display file in real time according to the updated attribute information of the file in the media database. so that when the user browses images through the file display APP, each image stored in the terminal device can be displayed quickly and in real time for the user.
  • the embodiment of the present application may further include the following S150 .
  • the terminal device updates the display state of the target file in the APP according to the updated attribute information of the target file in the media database.
  • the display state of the target file in the above-mentioned update file display APP may refer to: the target file is displayed in the file display APP (corresponding to the case where the file is newly added), or is no longer displayed in the file display APP (corresponding to the file being deleted), or the displayed content or position of the target file in the file display APP has changed (corresponding to the case of the file being modified).
  • the above-mentioned file display APP may be a gallery or photo album APP preset by the system, or may be an APP that has image capture and display functions and can access image files.
  • Third-party APPs the following two types of APPs are collectively referred to as galleries.
  • the following takes a gallery as an example for illustrative description.
  • a picture display list may be displayed in the user operation interface of the gallery, and thumbnail images corresponding to the pictures or videos may be displayed in the list, and the pictures or videos in the list may be displayed in sequence according to the generation time or the modification time.
  • the above-mentioned file display APP may be a music playback APP preset by the system, or may be a third-party APP that has a music playback function and can access audio files.
  • Such APPs are collectively referred to as audio players.
  • a track list may be displayed in the user operation interface of the music playing APP, and the track content corresponding to each audio file may be displayed in the list, such as name, size, type and/or cover thumbnail.
  • thumbnail images corresponding to image files or content of tracks corresponding to audio files may be stored in the media database, and these files are actually stored in the memory.
  • the gallery can call up the thumbnails stored in the media database to display thumbnails of the actual files.
  • users can intuitively browse a large number of pictures or videos in the gallery. If the user needs to view a certain image, the user can click on the thumbnail to trigger the terminal device to display the original image corresponding to the thumbnail. It can be understood that the resolution of the thumbnail is relatively low and takes up less space and memory than the corresponding original image.
  • the above S150 may specifically include the following three possible implementation manners:
  • the user generates a photo through the shooting portal or album portal of a third-party APP (such as instant social software), and the terminal device can respond to the user's operation, and store the generated photo in the memory and in the media database.
  • Add the attribute information of the photo, and correspondingly, the thumbnail corresponding to the photo will be added to the gallery.
  • the gallery refreshes to show thumbnails of the newly added photos.
  • the records in the media database and the picture display list in the gallery are synchronized with the actual image file in real time, which avoids the problem that the newly added image file cannot be displayed to the user in time due to the unsynchronized image file information of the terminal device, and improves the user experience.
  • the thumbnail image corresponding to the image file is canceled from being displayed in the gallery.
  • the user views the photos in the mobile phone through the album portal of the third-party APP (for example, instant social software) and selects one of the photos to delete, and the terminal device can respond to the user's operation and delete the photo selected by the user from the photo album. It is deleted from the storage, and the attribute information of the photo is deleted in the media database, and correspondingly, the thumbnail corresponding to the photo will no longer be displayed in the gallery. In this way, when a user browses pictures or videos through the gallery, the gallery refreshes and no longer displays thumbnails of deleted images. In this way, the records in the media database and the picture display list in the gallery are synchronized with the actual image file in real time, which avoids the problem that deleted images are still displayed to the user, and improves the user experience.
  • the third-party APP for example, instant social software
  • the thumbnail image corresponding to the image file is updated and displayed in the gallery.
  • the user views the photo through a third-party APP (such as image processing software) and retouches the photo
  • the terminal device responds to the user's operation and stores the retouched photo in the memory and in the media database.
  • the attribute information of the photo is updated, the corresponding thumbnail of the photo will be updated and displayed in the gallery accordingly.
  • the gallery refreshes and displays thumbnails of the retouched photos.
  • the records in the media database and the picture display list in the gallery are synchronized with the actual image files in real time.
  • updating the thumbnail image corresponding to the target file in the gallery mentioned in the third method may refer to updating the display content of the thumbnail image corresponding to the target file, or updating the display position of the thumbnail image corresponding to the target file, or updating the thumbnail image corresponding to the target file. It may refer to other possible update displays, which may be specifically determined according to actual usage conditions, which are not limited in this embodiment of the present application.
  • the records in the media database and the picture display list in the gallery can be synchronized with the actual image file in real time, which can ensure the consistency of the image file information in the terminal device. .
  • the gallery can quickly display the stored images for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
  • the above S150 may specifically include the following three possible implementations:
  • a user views a certain singer's music album and downloads some songs in the music album through a third-party APP (such as music playing software), and the terminal device can respond to the user's operation and store the downloaded songs in the memory. , and add attribute information corresponding to the downloaded song in the media database, and correspondingly add and display the content of the song corresponding to the song in the audio player of the terminal device.
  • the recording in the media database, the track list in the audio player and the actual audio file are synchronized in real time.
  • the user views the songs he has downloaded through a third-party APP (such as music playing software) and selects one of the songs to delete, and the terminal device can respond to the user's operation and delete the song selected by the user from the memory. , and delete the attribute information corresponding to the song in the media database, and correspondingly, the content of the track corresponding to the song is no longer displayed in the audio player of the terminal device. In this way, the recording in the media database, the track list in the audio player and the actual audio file are synchronized in real time.
  • a third-party APP such as music playing software
  • the third method if the attribute information of the audio file is updated in the media database, the content of the track corresponding to the audio file is updated and displayed in the audio player.
  • the user checks the songs he has downloaded through a third-party APP (such as music playing software) and selects one of the songs to perform a collection operation, and the terminal device updates the attribute information of the song in the media database in response to the user's operation, That is, adding a favorite tag to the song will update and display the content of the track corresponding to the song in the audio player accordingly.
  • a third-party APP such as music playing software
  • the records in the media database and the track list in the audio player can be synchronized with the actual audio file in real time, which can ensure the consistency of the audio file information in the terminal device. sex.
  • the audio player can quickly display the stored audio files for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
  • the foregoing embodiment is exemplarily described below by taking a scenario of adding a picture through a third-party APP installed in a mobile phone as an example.
  • the system APP such as camera APP
  • the third-party APP such as instant messaging software
  • the file system will be triggered to monitor that a new file has been added to the mobile phone memory card. At this time, the file is first determined.
  • the file information will be reported to the file daemon, and the file daemon will continue to report it to the media file scanning service, trigger the media file scanning service to start, perform file scanning, and call "file parsing". service” parses the file and finally inserts the parsed result into the media database.
  • the gallery monitors that there is a new image in the media database, the gallery will refresh and display the thumbnail of the newly added image.
  • the media database can be updated in time, so that the media database can be synchronized with the actual files in real time, and finally the gallery can display the pictures saved in the mobile phone in time.
  • the file display APP can update the display in real time according to the updated attribute information of the file in the media database.
  • the thumbnail of the file so that when the user browses images through the file display APP, each image stored in the terminal device can be displayed quickly and in real time for the user, so that the terminal device cannot display the newly added media files to the user in time or has been Deleted files are also still displayed to the user, improving the user experience.
  • the methods and operations implemented by the terminal device in the foregoing method embodiments may also be implemented by components (for example, chips or circuits) that can be used in the terminal device.
  • the terminal device implementing the method includes corresponding hardware structures and/or software modules for executing each function.
  • the present application can be implemented in hardware or a combination of hardware and computer software with the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein. Whether a function is performed by hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may use different methods to implement the described functions for each particular application, but such implementations should not be considered outside the scope of protection of this application.
  • the terminal device may be divided into functional modules according to the foregoing method examples.
  • each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module.
  • the above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules. It should be noted that the division of modules in the embodiments of the present application is illustrative, and is only a logical function division, and other feasible division manners may be used in actual implementation. The following description will be given by taking as an example that each function module is divided corresponding to each function.
  • FIG. 6 is a schematic block diagram of a media data processing apparatus 800 according to an embodiment of the present application.
  • the apparatus 800 may be used to perform the actions performed by the terminal device in the above method embodiments.
  • the apparatus 800 includes a processing unit 810 and a scanning unit 820 .
  • the processing unit 810 is configured to, when receiving a processing request for the target file sent by the first application, call the first interface of the file system of the apparatus 800 to process the target file according to the processing mode indicated by the processing request.
  • the scanning unit 820 is configured to perform file scanning if the target file is a media type file to obtain a scanning result corresponding to the target file.
  • the processing unit 810 is further configured to update the attribute information of the target file in the media database of the device 800 according to the scanning result corresponding to the target file.
  • the attribute information of the target file includes at least one of the following: storage path information of the target file, name information of the target file, file size information of the target file, file type information of the target file, last modification of the target file time information.
  • the processing unit 810 is further configured to call a second interface of the file system to determine whether the target file is a media type file.
  • the processing unit 810 is further configured to report a first message to the scanning unit 820 via a daemon process of the file system, where the first message is used to instruct to perform file scanning.
  • the scanning unit 820 is specifically configured to start the media file scanning service process according to the first message, and perform media file scanning.
  • processing unit 810 is specifically configured to:
  • the new interface of the file system is called to store the target file in the memory of the device 800;
  • the delete interface of the file system is called to delete the target file stored in the memory
  • the modification interface of the file system is invoked, the target file is modified, and the target file stored in the memory is updated to the modified target file.
  • processing unit 810 is specifically configured to:
  • the scanning result corresponding to the target file is that the target file is newly added to the memory of the device 800 and the attribute information of the target file does not exist in the media database, the attribute information of the target file is acquired, and the attribute information of the target file is added to the media database.
  • attribute information
  • the scanning result corresponding to the target file is that the target file in the memory is deleted, and the attribute information of the target file exists in the media database, then delete the attribute information of the target file in the media database;
  • the scan result corresponding to the target file is that the target file in the memory is modified and the attribute information of the target file before the modification exists in the media database, then the attribute information of the modified target file is obtained, and the pre-modification information in the media database is obtained.
  • the attribute information of the target file is replaced with the attribute information of the modified target file.
  • processing unit 810 is specifically configured to:
  • the newly added target file is parsed through the file parsing service process, and the attribute information of the target file is obtained;
  • the modified target file is parsed through the file analysis service process to obtain attribute information of the modified target file.
  • the processing unit 810 is further configured to, after updating the attribute information of the target file in the media database, update the display state of the target file in the file display application of the device 800 according to the updated attribute information of the target file in the media database .
  • processing unit 810 is specifically configured to:
  • the thumbnail corresponding to the target file is newly displayed in the file display application
  • the thumbnail image corresponding to the target file is canceled in the file display application
  • the thumbnail image corresponding to the target file is updated and displayed in the file display application.
  • an interface for determining whether the target file is a media file is added to the file system, and the actual file in the terminal device is changed (for example, added, deleted, or modified) through the APP operation.
  • the target file can be processed according to the processing method indicated by the processing request, and whether the changed file is a media file can be judged.
  • the information is synchronized with the actual media file in real time to ensure the consistency and integrity of the media file information. In this way, the gallery can quickly display the stored images for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
  • the apparatus 800 may correspond to executing the methods described in the embodiments of the present application, and the above-mentioned and other operations and/or functions of the units in the apparatus 800 are respectively to implement the corresponding processes of the methods, and are not described herein for the sake of brevity. Repeat.
  • FIG. 7 is a schematic structural diagram of a terminal device 900 provided by an embodiment of the present application.
  • the terminal device 900 includes: a processor 910 , a memory 920 , a communication interface 930 , and a bus 940 .
  • the processor 910 can be connected with the memory 920 .
  • the memory 920 may be used to store the program codes and data. Therefore, the memory 920 may be a storage unit within the processor 910 , or may be an external storage unit independent of the processor 910 , or may include a storage unit within the processor 910 and an external storage unit independent of the processor 910 . part.
  • the processor 910 in the terminal device 900 shown in FIG. 7 may correspond to the processing unit 810 in the apparatus 800 in FIG. 6 .
  • the terminal device 900 may further include a bus 940 .
  • the memory 920 and the communication interface 930 may be connected to the processor 910 through the bus 940 .
  • the bus 940 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus or the like.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus 940 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one line is shown in FIG. 7, but it does not mean that there is only one bus or one type of bus.
  • the processor 910 may adopt a central processing unit (central processing unit, CPU).
  • the processor may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • DSPs digital signal processors
  • ASICs application specific integrated circuits
  • FPGAs off-the-shelf programmable gate arrays
  • a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the processor 810 uses one or more integrated circuits to execute related programs, so as to implement the technical solutions provided by the embodiments of the present application.
  • the memory 920 which may include read-only memory and random access memory, provides instructions and data to the processor 910 .
  • a portion of processor 910 may also include non-volatile random access memory.
  • the processor 910 may also store device type information.
  • the processor 910 executes the computer-executed instructions in the memory 920 to perform the operation steps of the above-mentioned method.
  • terminal device 900 may correspond to the apparatus 800 in the embodiment of the present application, and the above-mentioned and other operations and/or functions of each unit in the apparatus 800 are to implement the corresponding processes of the above-mentioned methods, respectively, in order to It is concise and will not be repeated here.
  • embodiments of the present application further provide a computer-readable medium, where program codes are stored in the computer-readable medium, and when the computer program codes are run on a computer, the computer can execute the above aspects method in .
  • the embodiments of the present application further provide a computer program product
  • the computer program product includes: computer program code, when the computer program code runs on the computer, the computer program code enables the computer to perform the above aspects.
  • the terminal device or the network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer.
  • the hardware layer may include hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory (also called main memory).
  • the operating system of the operating system layer may be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system.
  • the application layer may include applications such as browsers, address books, word processing software, and instant messaging software.
  • the embodiments of the present application do not specifically limit the specific structure of the execution body of the methods provided by the embodiments of the present application, as long as the program in which the codes of the methods provided by the embodiments of the present application are recorded can be executed to execute the methods according to the embodiments of the present application.
  • the execution body of the method provided by the embodiment of the present application may be a terminal device or a network device, or a functional module in the terminal device or network device that can call a program and execute the program.
  • Computer readable media may include, but are not limited to, magnetic storage devices (eg, hard disks, floppy disks, or magnetic tapes, etc.), optical disks (eg, compact discs (CDs), digital versatile discs (DVDs), etc. ), smart cards and flash memory devices (eg, erasable programmable read-only memory (EPROM), cards, stick or key drives, etc.).
  • magnetic storage devices eg, hard disks, floppy disks, or magnetic tapes, etc.
  • optical disks eg, compact discs (CDs), digital versatile discs (DVDs), etc.
  • smart cards and flash memory devices eg, erasable programmable read-only memory (EPROM), cards, stick or key drives, etc.
  • Various storage media described herein may represent one or more devices and/or other machine-readable media for storing information.
  • the term "machine-readable medium” may include, but is not limited to, wireless channels and various other media capable of storing, containing, and/or carrying instructions and/or data.
  • processors mentioned in the embodiments of the present application may be a central processing unit (central processing unit, CPU), and may also be other general-purpose processors, digital signal processors (digital signal processors, DSP), application-specific integrated circuits ( application specific integrated circuit, ASIC), off-the-shelf programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the memory mentioned in the embodiments of the present application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.
  • the non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically programmable Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • Volatile memory may be random access memory (RAM).
  • RAM can be used as an external cache.
  • RAM may include the following forms: static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM) , double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synchlink DRAM, SLDRAM) and Direct memory bus random access memory (direct rambus RAM, DR RAM).
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • SDRAM double data rate synchronous dynamic random access memory
  • ESDRAM enhanced synchronous dynamic random access memory
  • SLDRAM synchronous link dynamic random access memory
  • Direct memory bus random access memory direct rambus RAM, DR RAM
  • the processor is a general-purpose processor, DSP, ASIC, FPGA or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components
  • the memory storage module
  • memory described herein is intended to include, but not be limited to, these and any other suitable types of memory.
  • the disclosed system, apparatus and method may be implemented in other manners.
  • the apparatus embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the functions, if implemented in the form of software functional units and sold or used as independent products, may be stored in a computer-readable storage medium.
  • the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution can be embodied in the form of a computer software product, and the computer software product is stored in a storage
  • the computer software product includes several instructions, the instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium may include, but is not limited to, various media that can store program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Human Computer Interaction (AREA)
  • Computer Hardware Design (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Virology (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application provides a media data processing method and apparatus, and a terminal device, and relates to the technical field of data processing. When an actual file in a terminal device is changed (for example, newly added, deleted or modified) by means of an app operation, an interface of a file system can be called, the file is processed on the basis of the processing means indicated by a processing request, and it is determined whether the changed file is a media file; if the changed file is a media file, file scanning is triggered, and file attribute information is updated in a media database according to a scanning result; as such, media file information in the media database is synchronized with an actual media file in real time to ensure the consistency and integrity of the media file information. In this way, a gallery can, by means of calling media file information that is updated in real time in a media database, quickly display stored images to a user in real time and improve the user experience.

Description

媒体数据处理方法、装置及终端设备Media data processing method, device and terminal device
本申请要求于2021年1月25日提交国家知识产权局、申请号为202110098318.8、申请名称为“媒体数据处理方法、装置及终端设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202110098318.8 and the application name "Media Data Processing Method, Apparatus and Terminal Equipment" submitted to the State Intellectual Property Office on January 25, 2021, the entire contents of which are incorporated by reference in in this application.
技术领域technical field
本申请涉及数据处理技术领域,尤其涉及一种媒体数据处理方法、装置及终端设备。The present application relates to the technical field of data processing, and in particular, to a method, apparatus and terminal device for processing media data.
背景技术Background technique
随着终端技术及通信技术的发展,智能手机安装的应用程序(application,APP)越来越丰富,使用功能越来越多样化,例如,用户可以采用智能手机拍照,或者从网络下载图片或视频,还可以删除智能手机已保存的某些图片。With the development of terminal technology and communication technology, the applications (application, APP) installed on smartphones are becoming more and more abundant, and their functions are becoming more and more diverse. For example, users can take pictures with smartphones, or download pictures or videos from the network. , you can also delete some pictures that your smartphone has saved.
目前,当用户通过智能手机中安装的某些APP新增图片或视频等媒体文件时,该媒体文件会被存储到存储器中,并且媒体数据库中会存储该媒体文件的属性信息(例如文件名称、文件大小、存储路径等)。当然,当用户通过某些APP删除智能手机中的媒体文件时,该媒体文件会被从存储器中删除,并且媒体数据库中该媒体文件的属性信息也会被删除。其中,存储于存储器中的媒体文件可以基于媒体数据库中存储的媒体文件的属性信息,通过智能手机中的图库或相册APP展示给用户。At present, when a user adds a media file such as a picture or video through some APP installed in the smartphone, the media file will be stored in the memory, and the attribute information of the media file (such as file name, file size, storage path, etc.). Of course, when a user deletes a media file in the smartphone through some APPs, the media file will be deleted from the memory, and the attribute information of the media file in the media database will also be deleted. Wherein, the media files stored in the memory can be displayed to the user through the gallery or photo album APP in the smart phone based on the attribute information of the media files stored in the media database.
然而,由于在通过某些APP新增或者删除媒体文件之后,媒体数据库没有及时刷新,例如可能需要智能手机重启后才会扫描刷新,导致智能手机无法及时将新增的媒体文件展示给用户,或者是已被删除的文件还仍然被展示给用户,因此用户体验较差。However, after adding or deleting media files through some apps, the media database is not refreshed in time. For example, the smartphone may need to be restarted to scan and refresh, so that the smartphone cannot display the newly added media files to the user in time, or The deleted files are still displayed to the user, so the user experience is poor.
发明内容SUMMARY OF THE INVENTION
本申请提供一种媒体数据处理方法、装置及终端设备,解决了现有技术中在通过APP访问并处理媒体文件时媒体数据库中的媒体文件信息无法实时刷新的问题。The present application provides a media data processing method, device and terminal device, which solve the problem in the prior art that the media file information in the media database cannot be refreshed in real time when accessing and processing media files through an APP.
为达到上述目的,本申请采用如下技术方案:To achieve the above object, the application adopts the following technical solutions:
第一方面,本申请提供一种媒体数据处理方法,该方法包括:当接收到第一应用发送的针对目标文件的处理请求时,调用终端设备的文件系统的第一接口,按照处理请求指示的处理方式对目标文件进行处理;若目标文件为媒体类型的文件,则执行文件扫描,得到目标文件对应的扫描结果;根据目标文件对应的扫描结果,在终端设备的媒体数据库中更新目标文件的属性信息。In a first aspect, the present application provides a method for processing media data, the method comprising: when receiving a processing request for a target file sent by a first application, calling a first interface of a file system of a terminal device, and according to the processing request instructed The processing method processes the target file; if the target file is a media type file, execute file scanning to obtain the scanning result corresponding to the target file; update the attribute of the target file in the media database of the terminal device according to the scanning result corresponding to the target file information.
通过上述方案,在通过APP操作使得终端设备中的实际文件发生变化(例如新增、删除或修改)时,可以调用文件系统的接口,按照处理请求指示的处理方式对目标文件进行处理,并判断发生变化的文件是否为媒体文件,若为媒体文件,则触发文件扫描,将媒体数据库中的媒体文件信息与实际媒体文件进行实时同步,保证媒体文件信息的一致性和完整性。这样,图库可以通过调用媒体数据库中实时更新的媒体文件信息,为用户实时快速地展示已存储图像,提升用户体验。Through the above solution, when the actual file in the terminal device changes (such as adding, deleting or modifying) through the APP operation, the interface of the file system can be called to process the target file according to the processing method indicated by the processing request, and determine Whether the changed file is a media file, if it is a media file, trigger file scanning to synchronize the media file information in the media database with the actual media file in real time to ensure the consistency and integrity of the media file information. In this way, the gallery can quickly display the stored images for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
其中,上述文件系统可以包括多个接口,例如新增接口、删除接口、修改接口和查看接口,分别用于执行新增文件、删除文件、修改文件和查看文件等操作。这样,终端设备可以通过文件系统的对应接口执行针对文件的新增、删除、修改或查看等操作。The above-mentioned file system may include multiple interfaces, such as adding interface, deleting interface, modifying interface, and viewing interface, which are respectively used to perform operations such as adding a file, deleting a file, modifying a file, and viewing a file. In this way, the terminal device can perform operations such as adding, deleting, modifying or viewing files through the corresponding interface of the file system.
其中,上述媒体数据库还可以称为多媒体数据库或者媒体存储数据库,用于存储媒体文件的相关属性信息,这些信息可以供APP调用,实现媒体文件的存取。媒体数据库可以包括各个媒体文件的相关属性信息,例如可以包括媒体文件的存储路径信息、文件名称信息、文件类型信息、文件大小信息和/或最后修改时间信息等文件属性信息;或者可以包括其他任意可能的属性信息,例如分类标签、收藏和/或私密等信息。The above-mentioned media database may also be referred to as a multimedia database or a media storage database, and is used to store relevant attribute information of media files, which can be called by an APP to realize access to media files. The media database may include relevant attribute information of each media file, for example, may include file attribute information such as storage path information, file name information, file type information, file size information, and/or last modification time information of the media file; or may include any other Possible attribute information such as category tags, favorites, and/or privacy.
在一些可能的实施方式中,上述目标文件的属性信息包括以下至少一项:目标文件的存储路径信息、目标文件的名称信息、目标文件的文件大小信息、目标文件的文件类型信息、目标文件的最后修改时间信息。In some possible implementations, the attribute information of the target file includes at least one of the following: storage path information of the target file, name information of the target file, file size information of the target file, file type information of the target file, Last modified time information.
其中,上述媒体类型的文件可以为图像文件,例如图片或照片,还可以为视频文件,或者音频文件,或者可以为其他任意可能的文件。The files of the above media types may be image files, such as pictures or photos, video files, or audio files, or any other possible files.
在一些可能的实施方式中,在上述若目标文件为媒体类型的文件,则执行文件扫描之前,上述方法还包括:调用文件系统的第二接口,判断目标文件是否为媒体类型的文件。In some possible implementations, before performing file scanning if the target file is a media type file, the method further includes: calling a second interface of the file system to determine whether the target file is a media type file.
其中,终端设备可以根据文件名的后缀来确定文件类型,以判断目标文件是否为媒体类型的文件。或者,还可以采用其他方式来判断目标文件是否为媒体文件,例如可以通过解析文件头信息,查看文件头信息是否包含指示媒体类型的字段,若包含指示媒体类型的字段,则确定目标文件为媒体文件。The terminal device may determine the file type according to the suffix of the file name, so as to determine whether the target file is a media type file. Alternatively, other methods can also be used to determine whether the target file is a media file. For example, by parsing the file header information, it can be checked whether the file header information contains a field indicating the media type. If it contains a field indicating the media type, it is determined that the target file is a media file. document.
如此,若通过文件系统的接口判断出目标文件是媒体文件,则文件系统向媒体扫描服务上报目标文件是媒体文件,以触发进行文件扫描,进而根据扫描结果,在媒体数据库中更新目标文件的属性信息。如此,本申请可以基于文件系统上报机制,实现媒体数据库与实际文件同步。In this way, if it is judged that the target file is a media file through the interface of the file system, then the file system reports to the media scanning service that the target file is a media file, to trigger file scanning, and then update the attribute of the target file in the media database according to the scanning result. information. In this way, the present application can realize the synchronization of the media database and the actual file based on the file system reporting mechanism.
需要说明的是,本申请实施例在文件系统中增加了判断目标文件是否为媒体文件这一接口,即,通过文件系统的接口,不但可以按照处理请求指示的处理方式(例如新增、删除或修改)对目标文件进行处理,而且还可以判断该请求处理的文件是否为媒体类型的文件。It should be noted that, in this embodiment of the present application, an interface for judging whether the target file is a media file is added to the file system, that is, through the interface of the file system, not only the processing method (such as adding, deleting or Modify) to process the target file, and it can also judge whether the file requested to be processed is a media type file.
其中,上述第一接口和第二接口可以为同一应用程序编程接口,在此情况下,该接口既具有按照处理请求指示的处理方式对目标文件进行处理的能力,也具有判断目标文件是否为媒体类型的文件的能力。或者,上述第一接口和第二接口可以分别为独立的两个应用程序编程接口,第一接口具有按照处理请求指示的处理方式对目标文件进行处理的能力,第二接口具有判断目标文件是否为媒体类型的文件的能力。第一接口和第二接口是否为同一接口,具体可以根据实际使用情况确定,本申请实施例不作限定。The first interface and the second interface may be the same application programming interface. In this case, the interface not only has the ability to process the target file according to the processing method indicated by the processing request, but also has the ability to determine whether the target file is a media ability to type files. Alternatively, the first interface and the second interface may be two independent application programming interfaces respectively, the first interface has the ability to process the target file according to the processing method indicated by the processing request, and the second interface has the ability to determine whether the target file is a The capability of the file of the media type. Whether the first interface and the second interface are the same interface can be specifically determined according to the actual usage, which is not limited in this embodiment of the present application.
在一些可能的实施方式中,在上述执行文件扫描之前,上述方法还包括:经由文件系统的守护进程向媒体文件扫描服务上报第一消息,该第一消息用于指示执行文件扫描。在此情况下,上述执行文件扫描,包括:根据第一消息,启动媒体文件扫描服 务进程,执行媒体文件扫描。In some possible implementation manners, before performing the file scanning, the method further includes: reporting a first message to the media file scanning service via a daemon process of the file system, where the first message is used to instruct the file scanning to be performed. In this case, the above-mentioned execution of file scanning includes: according to the first message, starting a media file scanning service process to execute media file scanning.
如此,可以实现文件系统与媒体文件扫描服务之间的信息交互,在文件系统处理媒体文件时即可触发媒体文件扫描服务进行文件扫描。In this way, the information interaction between the file system and the media file scanning service can be realized, and the media file scanning service can be triggered to perform file scanning when the file system processes the media files.
在一些可能的实施方式中,上述当接收到第一应用发送的针对目标文件的处理请求时,调用终端设备的文件系统的第一接口,按照处理请求指示的处理方式对目标文件进行处理,包括:In some possible implementations, when a processing request for the target file sent by the first application is received, the first interface of the file system of the terminal device is called to process the target file according to the processing method indicated by the processing request, including: :
若处理请求用于指示新增目标文件,则调用文件系统的新增接口,在终端设备的存储器中存储目标文件;If the processing request is used to instruct to add a new target file, call the new interface of the file system to store the target file in the memory of the terminal device;
或者,若处理请求用于指示删除目标文件,则调用文件系统的删除接口,删除存储器中存储的目标文件;Or, if the processing request is used to instruct to delete the target file, the delete interface of the file system is called to delete the target file stored in the memory;
或者,若处理请求用于指示修改目标文件,则调用文件系统的修改接口,修改目标文件,并将存储器中存储的目标文件更新为修改后的目标文件。Or, if the processing request is used to instruct to modify the target file, the modification interface of the file system is invoked, the target file is modified, and the target file stored in the memory is updated to the modified target file.
其中,上述修改目标文件可以是修改文件的存储路径,也可以是修改文件的内容,还可以是修改文件的名称,或者是以其他任意可能的方式修改文件。The above-mentioned modification target file may be the storage path of the modification file, the content of the modification file, the name of the modification file, or the modification of the file in any other possible manner.
其中,上述存储器可以是终端设备的内部存储器,也可以是外部存储器(例如可插拔的SD卡),具体可以根据实际使用需求确定,本申请实施例不作限定。The above-mentioned memory may be an internal memory of the terminal device, or may be an external memory (eg, a pluggable SD card), which may be specifically determined according to actual usage requirements, which is not limited in the embodiments of the present application.
其中,若被请求处理的文件是媒体文件,则有必要将该文件在媒体数据库中的相关属性信息进行同步更新,因此在判断被处理的文件为媒体文件时,可以触发进行文件扫描,进而可以根据扫描结果更新媒体数据库。Among them, if the file requested to be processed is a media file, it is necessary to synchronously update the relevant attribute information of the file in the media database. Therefore, when it is determined that the file to be processed is a media file, the file scanning can be triggered, and then the file scanning can be triggered. Update the media database based on the scan results.
在一些可能的实施方式中,上述根据目标文件对应的扫描结果,在终端设备的媒体数据库中更新目标文件的属性信息,包括:In some possible implementations, according to the scanning result corresponding to the target file, the attribute information of the target file is updated in the media database of the terminal device, including:
若目标文件对应的扫描结果为目标文件被新增到终端设备的存储器中、且媒体数据库中不存在目标文件的属性信息,则获取目标文件的属性信息,并在媒体数据库中新增目标文件的属性信息;If the scan result corresponding to the target file is that the target file is newly added to the storage of the terminal device, and the attribute information of the target file does not exist in the media database, the attribute information of the target file is acquired, and the attribute information of the target file is added to the media database. attribute information;
或者,若目标文件对应的扫描结果为存储器中的目标文件被删除、且媒体数据库中存在目标文件的属性信息,则删除媒体数据库中目标文件的属性信息;Or, if the scanning result corresponding to the target file is that the target file in the memory is deleted, and the attribute information of the target file exists in the media database, then delete the attribute information of the target file in the media database;
或者,若目标文件对应的扫描结果为存储器中的目标文件被修改、且媒体数据库中存在修改前的目标文件的属性信息,则获取修改后的目标文件的属性信息,并将媒体数据库中修改前的目标文件的属性信息替换为修改后的目标文件的属性信息。Or, if the scan result corresponding to the target file is that the target file in the memory is modified and the attribute information of the target file before the modification exists in the media database, then the attribute information of the modified target file is obtained, and the pre-modification information in the media database is obtained. The attribute information of the target file is replaced with the attribute information of the modified target file.
如此,在终端设备获取目标文件对应的扫描结果之后,可以根据扫描结果实现媒体数据库的更新,实现媒体数据库中的媒体文件信息与实际媒体文件实时同步。In this way, after the terminal device obtains the scan result corresponding to the target file, the media database can be updated according to the scan result, and the media file information in the media database can be synchronized with the actual media file in real time.
通过上述方案,可以基于文件系统上报机制,实现当媒体文件被APP修改后,媒体数据库中的媒体文件属性信息与实际媒体文件实时同步,保证终端设备中媒体文件信息的一致性,提升用户体验。Through the above solution, based on the file system reporting mechanism, after the media file is modified by the APP, the media file attribute information in the media database is synchronized with the actual media file in real time, ensuring the consistency of the media file information in the terminal device and improving the user experience.
在一些可能的实施方式中,上述获取目标文件的属性信息,包括:通过文件解析服务进程对新增的目标文件进行解析,得到目标文件的属性信息。In some possible implementations, obtaining the attribute information of the target file above includes: parsing the newly added target file through a file parsing service process to obtain the attribute information of the target file.
在一些可能的实施方式中,上述获取修改后的目标文件的属性信息,包括:通过文件解析服务进程对修改后的目标文件进行解析,得到修改后的目标文件的属性信息。In some possible implementations, obtaining the attribute information of the modified target file includes: parsing the modified target file through a file parsing service process to obtain the attribute information of the modified target file.
需要说明的是,终端设备中还可以配置有与媒体数据库关联的文件显示应用。该 文件显示应用可以根据媒体数据库中文件的属性信息,显示文件的缩略图,也就是说,文件显示应用在显示图像时依赖于媒体数据库中记录的文件属性信息。It should be noted that the terminal device may also be configured with a file display application associated with the media database. The file display application can display the thumbnail of the file according to the attribute information of the file in the media database, that is, the file display application relies on the file attribute information recorded in the media database when displaying images.
在一些可能的实施方式中,在上述媒体数据库中更新目标文件的属性信息之后,上述方法还包括:根据媒体数据库中目标文件的更新后的属性信息,更新终端设备的文件显示应用中目标文件的显示状态。In some possible implementations, after updating the attribute information of the target file in the media database, the above method further includes: updating the attribute information of the target file in the file display application of the terminal device according to the updated attribute information of the target file in the media database. Display state.
在一些可能的实施方式中,上述根据媒体数据库中目标文件的更新后的属性信息,更新终端设备的文件显示应用中目标文件的显示状态,包括:In some possible implementations, the above-mentioned updating the display state of the target file in the file display application of the terminal device according to the updated attribute information of the target file in the media database includes:
若媒体数据库中新增了目标文件的属性信息,则在文件显示应用中新增显示目标文件对应的缩略图;If the attribute information of the target file is newly added in the media database, the thumbnail corresponding to the target file is newly displayed in the file display application;
或者,若媒体数据库中删除了目标文件的属性信息,则在文件显示应用中取消显示目标文件对应的缩略图;Or, if the attribute information of the target file is deleted from the media database, the thumbnail image corresponding to the target file is canceled in the file display application;
或者,若媒体数据库中更新了目标文件的属性信息,则在文件显示应用中更新显示目标文件对应的缩略图。Or, if the attribute information of the target file is updated in the media database, the thumbnail image corresponding to the target file is updated and displayed in the file display application.
通过上述方案,在终端设备中的实际文件发生变化时,相应地同步更新媒体数据库中文件的属性信息,进而文件显示应用可以根据媒体数据库中文件的更新后的属性信息,实时更新显示文件的缩略图,这样在用户通过文件显示应用浏览图像时,可以为用户实时快速地展示终端设备中存储的各个图像,避免了终端设备无法及时将新增的媒体文件展示给用户或者是已被删除的文件还仍然被展示给用户的问题,提升用户体验。Through the above solution, when the actual file in the terminal device changes, the attribute information of the file in the media database is correspondingly updated synchronously, and the file display application can update the thumbnail of the displayed file in real time according to the updated attribute information of the file in the media database. Thumbnails, so that when the user browses images through the file display application, each image stored in the terminal device can be displayed quickly and in real time for the user, avoiding the terminal device being unable to display the newly added media files to the user in time or files that have been deleted. The problem is still being presented to the user, improving the user experience.
第二方面,本申请提供一种媒体数据处理装置,该装置包括用于执行上述第一方面中的方法的单元。该装置可对应于执行上述第一方面中描述的方法,该装置中的单元的相关描述请参照上述第一方面的描述,为了简洁,在此不再赘述。In a second aspect, the present application provides an apparatus for processing media data, the apparatus including a unit for executing the method in the above-mentioned first aspect. The apparatus may correspond to executing the method described in the first aspect. For the description of the units in the apparatus, please refer to the description of the first aspect. For brevity, details are not repeated here.
其中,上述第一方面描述的方法可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与上述功能相对应的模块或单元。例如,处理模块或单元、显示模块或单元等。The method described in the first aspect above may be implemented by hardware, or may be implemented by executing corresponding software by hardware. The hardware or software includes one or more modules or units corresponding to the above functions. For example, a processing module or unit, a display module or unit, and the like.
第三方面,本申请提供一种终端设备,该终端设备包括处理器,处理器与存储器耦合,存储器用于存储计算机程序或指令,处理器用于执行存储器存储的计算机程序或指令,使得第一方面中的方法被执行。In a third aspect, the present application provides a terminal device, the terminal device includes a processor, the processor is coupled with a memory, the memory is used for storing computer programs or instructions, and the processor is used for executing the computer programs or instructions stored in the memory, so that the first aspect The method in is executed.
例如,处理器用于执行存储器存储的计算机程序或指令,使得该装置执行第一方面中的方法。For example, the processor is configured to execute a computer program or instructions stored in the memory to cause the apparatus to perform the method of the first aspect.
第四方面,本申请提供一种计算机可读存储介质,其上存储有用于实现第一方面中的方法的计算机程序(也可称为指令或代码)。In a fourth aspect, the present application provides a computer-readable storage medium on which a computer program (which may also be referred to as instructions or codes) for implementing the method in the first aspect is stored.
例如,该计算机程序被计算机执行时,使得该计算机可以执行第一方面中的方法。For example, the computer program, when executed by a computer, causes the computer to perform the method of the first aspect.
第五方面,本申请提供一种芯片,包括处理器。处理器用于读取并执行存储器中存储的计算机程序,以执行第一方面及其任意可能的实现方式中的方法。In a fifth aspect, the present application provides a chip including a processor. The processor is adapted to read and execute the computer program stored in the memory to perform the method of the first aspect and any possible implementations thereof.
可选地,上述芯片还包括存储器,存储器与处理器通过电路或电线连接。Optionally, the above-mentioned chip further includes a memory, and the memory is connected to the processor through a circuit or a wire.
第六方面,本申请提供一种芯片系统,包括处理器。处理器用于读取并执行存储器中存储的计算机程序,以执行第一方面及其任意可能的实现方式中的方法。In a sixth aspect, the present application provides a chip system including a processor. The processor is adapted to read and execute the computer program stored in the memory to perform the method of the first aspect and any possible implementations thereof.
可选地,上述芯片系统还包括存储器,存储器与处理器通过电路或电线连接。Optionally, the chip system further includes a memory, and the memory is connected to the processor through a circuit or a wire.
第七方面,本申请提供一种计算机程序产品,该计算机程序产品包括计算机程序(也可称为指令或代码),该计算机程序被计算机执行时使得计算机实现第一方面中的方法。In a seventh aspect, the present application provides a computer program product, the computer program product comprising a computer program (also referred to as instructions or codes), which when executed by a computer causes the computer to implement the method in the first aspect.
可以理解的是,上述第二方面至第七方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。It can be understood that, for the beneficial effects of the foregoing second aspect to the seventh aspect, reference may be made to the relevant descriptions in the foregoing first aspect, which will not be repeated here.
附图说明Description of drawings
图1为相关技术中在通过APP处理媒体文件时APP与媒体数据库之间交互的系统架构图。FIG. 1 is a system architecture diagram of the interaction between the APP and the media database when processing media files through the APP in the related art.
图2为本申请实施例提供的媒体数据处理方法应用的操作系统的架构示意图。FIG. 2 is a schematic structural diagram of an operating system to which the media data processing method provided by the embodiment of the present application is applied.
图3为本申请实施例提供的一种媒体数据处理方法的流程示意图。FIG. 3 is a schematic flowchart of a media data processing method provided by an embodiment of the present application.
图4为本申请实施例提供的在通过APP处理媒体文件时APP与媒体数据库之间交互的系统架构图。FIG. 4 is a system architecture diagram of interaction between an APP and a media database when processing a media file through an APP according to an embodiment of the present application.
图5为本申请实施例提供的另一种媒体数据处理方法的流程示意图。FIG. 5 is a schematic flowchart of another media data processing method provided by an embodiment of the present application.
图6为本申请实施例提供的媒体数据处理装置的结构示意图。FIG. 6 is a schematic structural diagram of a media data processing apparatus provided by an embodiment of the present application.
图7为本申请实施例提供的终端设备的硬件示意图。FIG. 7 is a schematic hardware diagram of a terminal device according to an embodiment of the present application.
具体实施方式Detailed ways
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments It is a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
本文中术语“和/或”,是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。本文中符号“/”表示关联对象是或者的关系,例如A/B表示A或者B。The term "and/or" in this paper is an association relationship that describes an associated object, indicating that there can be three kinds of relationships, for example, A and/or B, which can mean that A exists alone, A and B exist at the same time, and B exists alone these three situations. The symbol "/" in this document indicates the relationship in which the associated object is or, for example, A/B indicates A or B.
本文中的说明书和权利要求书中的术语“第一”和“第二”等是用于区别不同的对象,而不是用于描述对象的特定顺序。例如,第一接口和第二接口等是用于区别不同的接口,而不是用于描述接口的特定顺序。The terms "first" and "second" and the like in the specification and claims herein are used to distinguish between different objects, rather than to describe a particular order of the objects. For example, the first interface, the second interface, etc. are used to distinguish different interfaces, rather than to describe a specific order of the interfaces.
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In the embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or illustrations. Any embodiments or designs described in the embodiments of the present application as "exemplary" or "such as" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present the related concepts in a specific manner.
在本申请实施例的描述中,除非另有说明,“多个”的含义是指两个或者两个以上,例如,多个处理单元是指两个或者两个以上的处理单元等;多个元件是指两个或者两个以上的元件等。In the description of the embodiments of the present application, unless otherwise specified, the meaning of "plurality" refers to two or more, for example, a plurality of processing units refers to two or more processing units, etc.; a plurality of An element refers to two or more elements or the like.
在手机等终端设备上通常都配置有存储器,可以存储图片和视频等各种图像文件,例如存储器可以为终端设备中内置存储器,或者可以为可插拔的存储卡(secure digital card,SD)。手机中的媒体数据库(data base,DB)中可以记录存储器中各图像文件的存储路径、文件名称、文件大小等文件属性信息。在手机上通常预置或安装有文件显示软件,比如手机中预制的图库或相册APP(可归于系统APP),或者手机中安装 的第三方APP,这类图像管理APP可以显示图片和视频等各种图像文件。A terminal device such as a mobile phone is usually equipped with a memory, which can store various image files such as pictures and videos. For example, the memory can be the built-in memory of the terminal device, or it can be a pluggable memory card (secure digital card, SD). The media database (data base, DB) in the mobile phone can record file attribute information such as the storage path, file name, and file size of each image file in the memory. File display software is usually preset or installed on the mobile phone, such as the pre-made gallery or photo album APP in the mobile phone (which can be attributed to the system APP), or the third-party APP installed in the mobile phone. This kind of image management APP can display pictures and videos. image file.
其中,手机系统的媒体扫描服务负责对存储器中存储的文件进行扫描,将存储器中文件的相关信息存储到媒体数据库中,供手机中的图像管理APP(例如手机中预制的系统APP或者手机中安装的第三方APP)调用。这样,手机中的各个APP可以根据用户对某些媒体文件的浏览需求,查询媒体数据库来展示对应的文件。Among them, the media scanning service of the mobile phone system is responsible for scanning the files stored in the memory, and storing the relevant information of the files in the memory in the media database for the image management APP in the mobile phone (for example, the pre-made system APP in the mobile phone or the installation in the mobile phone). third-party APP) call. In this way, each APP in the mobile phone can query the media database to display the corresponding files according to the user's browsing requirements for certain media files.
示例性的,在用户启动图像管理APP以浏览图像时,图像管理APP首先会调用媒体数据库中记录的图像文件信息,然后,通过媒体数据库中记录的图像文件信息去调用存储卡中存储的图像文件,从而显示相应的图像,实现图像浏览。Exemplarily, when the user starts the image management APP to browse images, the image management APP first calls the image file information recorded in the media database, and then calls the image file stored in the memory card through the image file information recorded in the media database. , so as to display the corresponding image and realize image browsing.
其中,在对存储器中存储的文件进行扫描之后,媒体数据库相应地会更新文件信息。下面列举了几种触发文件扫描的情况。Wherein, after scanning the files stored in the memory, the media database will update the file information accordingly. The following lists several situations that trigger file scanning.
情况一,APP发送广播。当通过某APP在手机中新增或者删除文件时,APP会主动发广播通知手机系统的媒体扫描服务进行扫描,以更新媒体数据库。In case one, the APP sends a broadcast. When a file is added or deleted in the mobile phone through an APP, the APP will actively send a broadcast to notify the media scanning service of the mobile phone system to scan to update the media database.
情况二,手机系统重启。当手机系统重启时,会触发媒体扫描服务递归扫描手机中所有的目录,并将各个媒体文件的相关信息存储到媒体数据库中。In the second case, the mobile phone system is restarted. When the mobile phone system is restarted, the media scanning service will be triggered to scan all the directories in the mobile phone recursively, and store the relevant information of each media file in the media database.
情况三,SD卡插拔。例如,当SD卡插入手机(SD卡挂载)时,会触发扫描SD卡中的文件。Case 3, SD card is inserted and unplugged. For example, when the SD card is inserted into the phone (SD card mount), it will trigger to scan the files in the SD card.
其中,上述情况二和情况三在实际应用中使用相对较少,上述情况一在实际应用中使用相对较多。Among them, the above-mentioned situations 2 and 3 are relatively rarely used in practical applications, and the above-mentioned situation 1 is relatively used in practical applications.
下面结合图1示例性地说明相关技术中在通过APP处理媒体文件时APP与媒体数据库交互的示意图。如图1所示,“媒体扫描接收”(对应于安卓操作系统中的MediaScannerReceiver)会监听Intent事件,该Intent事件可能是APP发出的广播通知,触发扫描单个指定文件。此外,该Intent事件也可能是操作系统发出的开机启动完成通知,触发全磁盘扫描;还可能是操作系统发出的SD卡挂载完成通知,触发SD卡扫描;为了图示内容简洁清楚,图1中并未示出。The following exemplarily illustrates a schematic diagram of the interaction between the APP and the media database when the APP processes media files in the related art with reference to FIG. 1 . As shown in Figure 1, "Media Scanner Receiver" (corresponding to MediaScannerReceiver in the Android operating system) will listen for an Intent event, which may be a broadcast notification sent by an APP, triggering scanning of a single specified file. In addition, the Intent event may also be the boot completion notification issued by the operating system, which triggers a full disk scan; it may also be the SD card mounting completion notification issued by the operating system, which triggers the SD card scan; for the sake of simplicity and clarity, Figure 1 is not shown.
其中,“媒体扫描服务”(对应于安卓系统中的MediaScannerService)可以基于APP发出的广播,实现“媒体扫描”(对应于安卓操作系统中的MediaScanner)的实例化,以及媒体数据库的更新等工作。“媒体提供”(对应于安卓操作系统中的MediaProvider)作为媒体数据库的封装类,用于创建并维护数据库,并对外提供统一资源标志符(uniform resource identifier,URI),以实现对数据库的新增、删除、修改或查询(简称为增删改查)功能。Among them, the "Media Scanner Service" (corresponding to the MediaScannerService in the Android system) can realize the instantiation of the "Media Scanner" (corresponding to the MediaScanner in the Android operating system) and the update of the media database based on the broadcast sent by the APP. "Media Provider" (corresponding to MediaProvider in the Android operating system) is used as the encapsulation class of the media database, which is used to create and maintain the database, and provide a uniform resource identifier (URI) externally to realize the addition of the database. , delete, modify or query (referred to as CRUD) function.
一方面,从通过APP增删改查媒体文件的角度来讲(参考图1中虚线所示路径),APP可以通过“内容解决”(对应于安卓操作系统中的ContentResolver)调用“媒体提供”的接口,对“媒体提供”中的数据库数据进行增删改查操作。On the one hand, from the perspective of adding, deleting, modifying and checking media files through the APP (refer to the path shown by the dotted line in Figure 1), the APP can call the interface of "media provision" through "content resolution" (corresponding to ContentResolver in the Android operating system) , to add, delete, modify, and query the database data in "Media Provision".
另一方面,从APP发送广播的角度来讲(参考图1中实线所示路径),当在手机中通过APP增删改查文件时,APP发广播,“媒体扫描接收”在接收到该广播后,触发媒体扫描服务启动,然后调用“媒体扫描”进行扫描,同时还会通过“元数据解析”(对应于安卓操作系统中的MetaDataRetriever)对扫描的文件进行解析。进一步的,“媒体提供”根据文件扫描结果或者解析结果更新媒体数据库。On the other hand, from the perspective of APP sending broadcasts (refer to the path shown by the solid line in Figure 1), when adding, deleting, modifying and checking files through the APP in the mobile phone, the APP broadcasts, and "media scan and receive" receives the broadcast. After that, the media scan service is triggered to start, and then "media scan" is called to scan, and the scanned files are also parsed through "metadata parsing" (corresponding to MetaDataRetriever in the Android operating system). Further, "media provision" updates the media database according to the file scanning result or the parsing result.
然而,由于目前有些APP不够规范,存在APP新增或者删除文件后不能及时广 播通知手机系统进行扫描的情况,或者是由于手机系统升级原因,存在某些APP新增或者删除文件后不能再通过广播方式通知手机系统进行扫描的情况,这样导致的结果是媒体数据库无法及时更新。也就是说,一旦APP在新增、删除或修改文件之后没有广播通知(如图1中的×所示)手机系统进行文件扫描,则会出现媒体数据库更新不及时的问题。进一步的,由于媒体数据库更新不及时,会导致媒体数据库中记录的文件信息和存储器中存储的实际文件不一致或不同步,最终可能产生各种问题,例如图库刷新慢,图片长时间无法显示,手机可能无法及时将新增的媒体文件展示给用户,或者是已被删除的文件还仍然被展示给用户。在一些情况下,媒体数据库需要直到手机系统重启之后才能通过扫描被更新;在此情况下,由于不仅要对手机中所有目录进行扫描,而且还需要对未同步文件进行解析,这样会大大增加手机重启后的负担。鉴于此,如何使得媒体数据库和实际文件实时保持一致,是本申请实施例所要解决的技术问题。However, due to the fact that some APPs are not standardized enough at present, there are situations in which the APP cannot broadcast and notify the mobile phone system to scan in time after adding or deleting files. In this way, the mobile phone system is notified of the scanning situation, and the result is that the media database cannot be updated in time. That is to say, once the APP does not broadcast a notification after adding, deleting or modifying a file (as shown by the × in Figure 1) the mobile phone system scans the file, there will be a problem that the media database is not updated in time. Further, due to the untimely update of the media database, the file information recorded in the media database will be inconsistent or out of sync with the actual files stored in the memory, which may eventually lead to various problems, such as slow refresh of the gallery, pictures that cannot be displayed for a long time, and mobile phones. The newly added media files may not be displayed to the user in time, or the deleted files may still be displayed to the user. In some cases, the media database cannot be updated by scanning until the mobile phone system is restarted; in this case, since not only all directories in the mobile phone are scanned, but also unsynchronized files need to be parsed, which will greatly increase the number of mobile phones. The burden after rebooting. In view of this, how to keep the media database and the actual file consistent in real time is a technical problem to be solved by the embodiments of the present application.
本申请实施例提供一种媒体数据处理方法及终端设备,可以基于文件系统上报来实现媒体数据库与实际文件同步。具体的,当接收到第一应用发送的针对目标文件的处理请求时,调用终端设备的文件系统的第一接口,按照处理请求指示的处理方式对目标文件进行处理;若目标文件为媒体类型的文件,则执行文件扫描,得到目标文件对应的扫描结果;根据目标文件对应的扫描结果,在终端设备的媒体数据库中更新目标文件的属性信息。通过该方案,在通过APP操作使得终端设备中的实际文件发生变化(例如新增、删除或修改)时,调用文件系统的接口,按照处理请求指示的处理方式对目标文件进行处理,并判断发生变化的文件是否为媒体文件,若为媒体文件,则触发文件扫描,将媒体数据库中的媒体文件信息与实际媒体文件进行实时同步,保证媒体文件信息的一致性和完整性。这样,图库可以通过调用媒体数据库中实时更新的媒体文件信息,为用户实时快速地展示已存储图像,提升用户体验。本申请实施例通过文件系统上报机制,触发文件扫描,以便将媒体数据库中的媒体文件信息与实际媒体文件进行实时同步,保证媒体文件信息的一致性和完整性,提升用户体验。Embodiments of the present application provide a media data processing method and a terminal device, which can realize synchronization between a media database and an actual file based on file system reporting. Specifically, when a processing request for the target file sent by the first application is received, the first interface of the file system of the terminal device is called to process the target file according to the processing method indicated by the processing request; if the target file is a media type file, perform file scanning to obtain the scanning result corresponding to the target file; update the attribute information of the target file in the media database of the terminal device according to the scanning result corresponding to the target file. Through this solution, when the actual file in the terminal device changes (such as adding, deleting or modifying) through the APP operation, the interface of the file system is called to process the target file according to the processing method indicated by the processing request, and it is judged that the occurrence of Whether the changed file is a media file, if it is a media file, trigger file scanning to synchronize the media file information in the media database with the actual media file in real time to ensure the consistency and integrity of the media file information. In this way, the gallery can quickly display the stored images for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience. The embodiments of the present application trigger file scanning through a file system reporting mechanism, so as to synchronize media file information in the media database with actual media files in real time, ensure the consistency and integrity of media file information, and improve user experience.
本申请实施例中的终端设备可以为具有操作系统的终端设备。该操作系统可以为安卓(Android)操作系统,可以为ios操作系统,还可以为其他可能的操作系统,本申请实施例不作具体限定。The terminal device in this embodiment of the present application may be a terminal device having an operating system. The operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, which are not specifically limited in the embodiments of the present application.
下面以安卓操作系统为例,介绍一下本申请实施例提供的媒体数据处理方法所应用的软件环境。The following takes the Android operating system as an example to introduce the software environment to which the media data processing method provided by the embodiment of the present application is applied.
如图2所示,为本申请实施例提供的一种可能的安卓操作系统的架构示意图。在图2中,安卓操作系统的架构包括4层,分别为:应用程序层、应用程序框架层、系统运行库层和内核层(具体可以为Linux内核层)。As shown in FIG. 2 , it is a schematic diagram of the architecture of a possible Android operating system provided by an embodiment of the present application. In FIG. 2, the architecture of the Android operating system includes four layers, namely: an application layer, an application framework layer, a system runtime layer, and a kernel layer (specifically, a Linux kernel layer).
其中,应用程序层包括安卓操作系统中的各个应用程序(包括系统应用程序和第三方应用程序)。The application layer includes various applications (including system applications and third-party applications) in the Android operating system.
应用程序框架层是应用程序的框架,开发人员可以在遵守应用程序的框架的开发原则的情况下,基于应用程序框架层开发一些应用程序。The application framework layer is the framework of the application, and developers can develop some applications based on the application framework layer under the condition of complying with the development principles of the framework of the application.
系统运行库层包括库(也称为系统库)和安卓操作系统运行环境。库主要为安卓操作系统提供其所需的各类资源。安卓操作系统运行环境用于为安卓操作系统提供软 件环境。The system runtime layer includes libraries (also called system libraries) and the Android operating system runtime environment. The library mainly provides various resources required by the Android operating system. The Android operating system operating environment is used to provide a software environment for the Android operating system.
内核层是安卓操作系统的操作系统层,属于安卓操作系统软件层次的最底层。内核层基于Linux内核为安卓操作系统提供核心系统服务和与硬件相关的驱动程序。The kernel layer is the operating system layer of the Android operating system and belongs to the bottom layer of the Android operating system software layer. The kernel layer provides core system services and hardware-related drivers for the Android operating system based on the Linux kernel.
以安卓操作系统为例,本申请实施例中,开发人员可以基于上述如图2所示的安卓操作系统的系统架构,开发实现本申请实施例提供的媒体数据处理方法的软件程序,从而使得该媒体数据处理方法可以基于如图2所示的安卓操作系统运行。即处理器或者终端设备可以通过在安卓操作系统中运行该软件程序实现本申请实施例提供的媒体数据处理方法。Taking the Android operating system as an example, in this embodiment of the present application, a developer can develop a software program for implementing the media data processing method provided by the embodiment of the present application based on the system architecture of the Android operating system as shown in FIG. The media data processing method can run based on the Android operating system as shown in FIG. 2 . That is, the processor or the terminal device can implement the media data processing method provided by the embodiments of the present application by running the software program in the Android operating system.
本申请实施例中的终端设备可以为移动终端,也可以为非移动终端。示例性的,移动终端可以为手机、平板电脑、笔记本电脑、掌上电脑、车载终端、可穿戴设备、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本或者个人数字助理(personal digital assistant,PDA)等,非移动终端可以为个人计算机(personal computer,PC)、电视机(television,TV)、柜员机或者自助机等,本申请实施例不作具体限定。The terminal device in this embodiment of the present application may be a mobile terminal or a non-mobile terminal. Exemplarily, the mobile terminal may be a mobile phone, a tablet computer, a notebook computer, a palmtop computer, a vehicle-mounted terminal, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (personal digital assistant, PDA), etc., the non-mobile terminal may be a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which are not specifically limited in the embodiments of the present application.
本申请实施例提供的媒体数据处理方法的执行主体可以为上述的终端设备,也可以为该终端设备中能够实现该媒体数据处理方法的功能模块和/或功能实体,具体的可以根据实际使用需求确定,本申请实施例不作限定。下面以终端设备为例,结合附图对本申请实施例提供的媒体数据处理方法进行示例性的说明。The execution subject of the media data processing method provided by the embodiment of the present application may be the above-mentioned terminal device, or may be a functional module and/or functional entity in the terminal device capable of implementing the media data processing method, and the specific implementation may be based on actual usage requirements. It is confirmed that the embodiments of the present application are not limited. The media data processing method provided by the embodiment of the present application is exemplarily described below by taking a terminal device as an example and with reference to the accompanying drawings.
图3是本申请实施例提供的媒体数据处理方法的流程示意图,该媒体数据处理方法应用于终端设备,该终端设备中预置有系统APP,并且安装有第三方APP,为了便于描述,以下将系统APP和第三方APP统称为第一应用,该终端设备中配置有与第一应用关联的文件系统和媒体数据库,该文件系统用于执行针对文件的新增、删除、修改和查看操作,媒体数据库用于存储媒体文件的相关信息,供第一应用调用,以便为用户展示媒体文件。参照图3所示,该方法100包括下述的步骤S110-S140。3 is a schematic flowchart of a media data processing method provided by an embodiment of the present application. The media data processing method is applied to a terminal device. The terminal device is preset with a system APP and installed with a third-party APP. For ease of description, the following will be The system APP and the third-party APP are collectively referred to as the first application. The terminal device is configured with a file system and a media database associated with the first application. The file system is used to perform operations for adding, deleting, modifying and viewing files. The database is used to store the relevant information of the media file for the first application to call, so as to display the media file for the user. Referring to FIG. 3 , the method 100 includes the following steps S110-S140.
S110,当接收到第一应用发送的针对目标文件的处理请求时,终端设备调用文件系统的第一接口,按照处理请求指示的处理方式对目标文件进行处理。S110: When receiving the processing request for the target file sent by the first application, the terminal device invokes the first interface of the file system to process the target file according to the processing method indicated by the processing request.
其中,文件系统是操作系统中以文件方式管理计算机软件资源的软件和被管理的文件和数据结构(如目录和索引表等)的集合,可以用于执行针对文件的新增、删除、修改或查看等操作。从系统角度来看,文件系统是对文件存储器的存储空间进行组织、分配和回收,负责文件的存储、检索、共享和保护。从用户角度来看,根据所需文件的文件名即可存取文件中的信息,即“按名存取”。Among them, the file system is a collection of software and managed files and data structures (such as directories and index tables) that manage computer software resources in the form of files in the operating system, which can be used to perform addition, deletion, modification or modification of files. View and other operations. From the system point of view, the file system organizes, allocates and reclaims the storage space of the file storage, and is responsible for the storage, retrieval, sharing and protection of files. From the user's point of view, the information in the file can be accessed according to the file name of the desired file, that is, "access by name".
在本申请实施例中,文件系统可以包括多个接口,例如新增接口、删除接口、修改接口和查看接口,分别用于执行新增文件、删除文件、修改文件和查看文件等操作。这样,终端设备可以通过文件系统的对应接口执行针对文件的新增、删除、修改或查看等操作。In this embodiment of the present application, the file system may include multiple interfaces, such as an add interface, a delete interface, a modification interface, and a view interface, which are respectively used to perform operations such as adding a file, deleting a file, modifying a file, and viewing a file. In this way, the terminal device can perform operations such as adding, deleting, modifying or viewing files through the corresponding interface of the file system.
可选的,上述S110具体可以包括如下三种可能实现方式:Optionally, the foregoing S110 may specifically include the following three possible implementation manners:
方式一,若处理请求用于指示新增目标文件,则终端设备调用文件系统的新增接口,在终端设备的存储器中存储目标文件。Manner 1, if the processing request is used to instruct to add a target file, the terminal device calls the new interface of the file system to store the target file in the memory of the terminal device.
示例性的,上述新增目标文件可以是通过相机拍摄得到图片或视频文件,也可以是从网络下载图片或视频文件,还可以是从网络下载音频文件,或者是以其他任意可 能的方式新增文件,具体可以根据实际使用需求确定,本申请实施例不作限定。Exemplarily, the above-mentioned newly added target file may be a picture or video file obtained by taking a camera, or may be a picture or a video file downloaded from the network, or an audio file may be downloaded from the network, or added in any other possible way. The file can be specifically determined according to actual use requirements, which is not limited in the embodiment of the present application.
方式二,若处理请求用于指示删除目标文件,则终端设备调用文件系统的删除接口,删除存储器中存储的目标文件。In the second way, if the processing request is used to instruct to delete the target file, the terminal device calls the delete interface of the file system to delete the target file stored in the memory.
方式三,若处理请求用于指示修改目标文件,则终端设备调用文件系统的修改接口,修改目标文件,并将存储器中存储的目标文件替换或更新为修改后的目标文件。Manner 3: If the processing request is used to instruct to modify the target file, the terminal device calls the modification interface of the file system to modify the target file, and replaces or updates the target file stored in the memory with the modified target file.
示例性的,上述修改目标文件可以是修改文件的存储路径,也可以是修改文件的内容,还可以是修改文件的名称,或者是以其他任意可能的方式修改文件,具体可以根据实际使用需求确定,本申请实施例不作限定。Exemplarily, the above-mentioned modification target file may be the storage path of the modification file, the content of the modification file, the name of the modification file, or the modification of the file in any other possible way, which can be determined according to actual use requirements. , the embodiments of the present application are not limited.
其中,终端设备的存储器可以是内部存储器,也可以是外部存储器(例如可插拔的SD卡),具体可以根据实际使用需求确定,本申请实施例不作限定。Wherein, the memory of the terminal device may be an internal memory or an external memory (for example, a pluggable SD card), which may be specifically determined according to actual usage requirements, which is not limited in this embodiment of the present application.
S120,终端设备调用文件系统的第二接口,判断目标文件是否为媒体类型的文件。S120, the terminal device invokes the second interface of the file system to determine whether the target file is a file of a media type.
本申请实施例在文件系统中增加了判断目标文件是否为媒体文件这一接口,即,通过文件系统的接口,不但可以按照处理请求指示的处理方式(例如新增、删除或修改)对目标文件进行处理,而且还可以判断该请求处理的文件是否为媒体类型的文件(可简称为媒体文件)。This embodiment of the present application adds an interface for determining whether a target file is a media file in the file system, that is, through the interface of the file system, not only can the target file be processed according to the processing method (such as adding, deleting or modifying) indicated by the processing request processing, and it can also be judged whether the file requested to be processed is a media type file (may be referred to as a media file for short).
需要说明的是,上述第一接口和第二接口可以为同一应用程序编程接口,在此情况下,该接口既具有按照处理请求指示的处理方式对目标文件进行处理的能力,也具有判断目标文件是否为媒体类型的文件的能力。或者,上述第一接口和第二接口可以分别为独立的两个应用程序编程接口,第一接口具有按照处理请求指示的处理方式对目标文件进行处理的能力,第二接口具有判断目标文件是否为媒体类型的文件的能力。第一接口和第二接口是否为同一接口,具体可以根据实际使用情况确定,本申请实施例不作限定。It should be noted that the above-mentioned first interface and the second interface may be the same application programming interface. In this case, the interface not only has the ability to process the target file according to the processing method indicated by the processing request, but also has the ability to judge the target file. Whether the file is capable of media type. Alternatively, the first interface and the second interface may be two independent application programming interfaces respectively, the first interface has the ability to process the target file according to the processing method indicated by the processing request, and the second interface has the ability to determine whether the target file is a The capability of the file of the media type. Whether the first interface and the second interface are the same interface can be specifically determined according to the actual usage, which is not limited in this embodiment of the present application.
还需要说明的是,这里是以在文件系统中增加了判断目标文件是否为媒体文件这一接口,并通过调用该接口判断目标文件是否为媒体文件为例进行示例性地说明,可以理解,在实际实现时,本申请实施例还可以通过其他可能方式来判断目标文件是否为媒体文件这一步骤,例如文件系统可以将目标文件被处理的事件通知媒体文件扫描服务,媒体文件扫描服务先判断目标文件是否为媒体文件,然后根据判断结果确定是否进行文件扫描,具体的,若目标文件为媒体文件,则进行文件扫描;若目标文件不是媒体文件,则不作文件扫描。具体可以根据实际使用需求确定,本申请实施例不作限定。It should also be noted that here is an example of adding an interface for judging whether the target file is a media file in the file system, and judging whether the target file is a media file by calling the interface. It can be understood that in In actual implementation, the embodiment of the present application may also use other possible methods to determine whether the target file is a media file. For example, the file system may notify the media file scanning service of the event that the target file is processed, and the media file scanning service first determines the target file. Whether the file is a media file, and then determine whether to perform file scanning according to the judgment result. Specifically, if the target file is a media file, file scanning is performed; if the target file is not a media file, file scanning is not performed. Specifically, it can be determined according to actual use requirements, which is not limited in the embodiment of the present application.
可选的,在本申请实施例中,上述媒体类型的文件可以为图像文件,例如图片或照片,还可以为视频文件,或者音频文件,或者可以为其他任意可能的文件,具体可以根据实际使用需求确定,本申请实施例不作限定。Optionally, in this embodiment of the present application, the files of the above-mentioned media types may be image files, such as pictures or photos, may also be video files, or audio files, or may be any other possible files. The requirements are determined, which is not limited in the embodiments of the present application.
可选的,终端设备可以根据文件名的后缀来确定文件类型,以判断目标文件是否为媒体类型的文件。示例性的,常见的图像文件名后缀可以包括.BMP、.GIF、.JPEG、.PSD或者.PNG。常见的音频文件名后缀可以包括.WAV、.MP1、.MP2、.MP3或者.MP4。常见的视频文件名后缀可以包括.GIF、.AVI、.MOV、.MPEG或者.RM。当然,还可以采用其他方式来判断目标文件是否为媒体文件,例如可以通过解析文件头信息,查看文件头信息是否包含指示媒体 类型的字段,若包含指示媒体类型的字段,则确定目标文件为媒体文件。Optionally, the terminal device may determine the file type according to the suffix of the file name to determine whether the target file is a media type file. Exemplarily, common image file name suffixes may include .BMP, .GIF, .JPEG, .PSD, or .PNG. Common audio file name suffixes can include .WAV, .MP1, .MP2, .MP3, or .MP4. Common video file name suffixes can include .GIF, .AVI, .MOV, .MPEG, or .RM. Of course, other methods can also be used to determine whether the target file is a media file. For example, by parsing the file header information, it is possible to check whether the file header information contains a field indicating the media type. If it contains a field indicating the media type, the target file is determined to be a media file. document.
在本申请实施例中,若终端设备判断目标文件是媒体文件,则终端设备继续执行下述的S130。若终端设备判断目标文件不是媒体文件,则终端设备结束操作。In this embodiment of the present application, if the terminal device determines that the target file is a media file, the terminal device continues to perform the following S130. If the terminal device determines that the target file is not a media file, the terminal device ends the operation.
S130,终端设备执行文件扫描,得到目标文件对应的扫描结果。S130, the terminal device performs file scanning to obtain a scanning result corresponding to the target file.
在本申请实施例中,若被请求处理的文件是媒体文件,则有必要将该文件在媒体数据库中的相关属性信息进行同步更新,因此在判断被处理的文件为媒体文件时,可以触发进行文件扫描,进而可以根据扫描结果更新媒体数据库。In the embodiment of the present application, if the file requested to be processed is a media file, it is necessary to synchronously update the relevant attribute information of the file in the media database. Therefore, when it is determined that the processed file is a media file, the File scanning, which in turn can update the media database based on the scan results.
下面示例性地描述文件扫描过程。在媒体扫描服务中可以开启后台线程执行文件扫描动作,在扫描开始之前会发送扫描开始的广播,在扫描完成之后则发送扫描完成的广播。并且,在扫描开始之前可以执行预扫描的动作,遍历媒体数据库中的每一条数据(即文件属性信息),检查每一条数据所对应的实际文件是否存在于存储器中。在预扫描之后,终端设备对内/外部存储器上的各个文件夹逐个遍历扫描(称为存储器扫描),当扫描到目标文件时,查询媒体数据库中是否存在该目标文件的相关属性信息。The file scanning process is exemplarily described below. In the media scanning service, a background thread can be started to perform the file scanning action. Before the scanning starts, the scanning start broadcast will be sent, and the scanning completion broadcast will be sent after the scanning is completed. Moreover, before the scan starts, a pre-scan action can be performed to traverse each piece of data (ie, file attribute information) in the media database to check whether the actual file corresponding to each piece of data exists in the memory. After pre-scanning, the terminal device traverses and scans each folder on the internal/external memory one by one (referred to as memory scanning), and when a target file is scanned, it queries the media database for relevant attribute information of the target file.
这样,通过上述预扫描和存储器扫描,可以获得如下几种可能的扫描结果:In this way, through the above pre-scan and memory scan, the following possible scan results can be obtained:
结果一:目标文件被新增到存储器中且媒体数据库中不存在目标文件的属性信息。Result 1: The target file is added to the storage and the attribute information of the target file does not exist in the media database.
结果二:存储器中的目标文件被删除且媒体数据库中存在目标文件的属性信息。Result 2: The target file in the storage is deleted and the attribute information of the target file exists in the media database.
结果三:存储器中的目标文件被修改且媒体数据库中存在目标文件的属性信息。Result three: The target file in the storage is modified and the attribute information of the target file exists in the media database.
在终端设备获取目标文件对应的扫描结果之后,可以根据扫描结果实现媒体数据库的更新,以便将媒体数据库中的媒体文件信息与实际媒体文件进行实时同步。After the terminal device obtains the scan result corresponding to the target file, the media database can be updated according to the scan result, so as to synchronize the media file information in the media database with the actual media file in real time.
S140,终端设备根据目标文件对应的扫描结果,在媒体数据库中更新目标文件的属性信息。S140, the terminal device updates the attribute information of the target file in the media database according to the scanning result corresponding to the target file.
其中,上述媒体数据库也可以称为多媒体数据库或者媒体存储数据库,用于存储媒体文件的相关属性信息,这些信息可以供APP调用,实现媒体文件的存取。The above-mentioned media database may also be referred to as a multimedia database or a media storage database, and is used to store relevant attribute information of media files, which can be invoked by an APP to realize access to media files.
可选的,媒体数据库可以包括各个媒体文件的相关属性信息,例如可以包括媒体文件的存储路径信息、文件名称信息、文件类型信息、文件大小信息和/或最后修改时间信息等文件属性信息;或者可以包括其他任意可能的属性信息,例如分类标签、收藏和/或私密等信息。媒体文件的属性信息具体可以根据实际使用需求确定,本申请实施例不作限定。Optionally, the media database may include relevant attribute information of each media file, for example, may include file attribute information such as storage path information, file name information, file type information, file size information and/or last modification time information of the media file; or Any other possible attribute information may be included, such as category tags, favorites, and/or privacy. The attribute information of the media file may be specifically determined according to actual usage requirements, which is not limited in this embodiment of the present application.
在本申请实施例中,若通过文件系统的接口判断出目标文件是媒体文件,则文件系统向媒体扫描服务进程上报目标文件是媒体文件,以触发执行文件扫描,进而根据扫描结果,在媒体数据库中更新目标文件的属性信息,即基于文件系统上报机制来实现媒体数据库与实际文件同步。In the embodiment of the present application, if it is determined through the interface of the file system that the target file is a media file, the file system reports to the media scanning service process that the target file is a media file, so as to trigger the execution of file scanning, and then according to the scanning result, in the media database The attribute information of the target file is updated in the file system, that is, the synchronization between the media database and the actual file is realized based on the file system reporting mechanism.
其中,终端设备可以经由文件系统的守护进程向媒体文件扫描服务上报消息。如此实现文件系统与媒体文件扫描服务之间的信息交互,在文件系统处理媒体文件时即可触发媒体文件扫描服务进行文件扫描。The terminal device may report messages to the media file scanning service via the daemon process of the file system. In this way, the information interaction between the file system and the media file scanning service is realized, and when the file system processes the media files, the media file scanning service can be triggered to perform file scanning.
可选的,上述S140具体可以包括如下三种可能实现方式:Optionally, the foregoing S140 may specifically include the following three possible implementation manners:
方式一,若目标文件对应的扫描结果为目标文件被新增到存储器中、且媒体数据库中不存在目标文件的属性信息,则终端设备获取目标文件的属性信息,并在媒体数 据库中新增目标文件的属性信息。Mode 1, if the scan result corresponding to the target file is that the target file is newly added to the memory, and the attribute information of the target file does not exist in the media database, the terminal device obtains the attribute information of the target file, and adds the target file in the media database. Attribute information for the file.
其中,终端设备启动媒体文件扫描服务进程进行扫描,查找到目标文件,并查询媒体数据库中是否存在该目标文件的相关属性信息,若不存在,则启动文件解析服务进程对目标文件进行解析,得到目标文件的属性信息。进一步的,将得到目标文件的属性信息添加到媒体数据库中。The terminal device starts the media file scanning service process to scan, finds the target file, and queries whether the relevant attribute information of the target file exists in the media database, and if not, starts the file parsing service process to parse the target file, and obtains Attribute information of the target file. Further, the attribute information of the obtained target file is added to the media database.
示例性的,通过第三方APP新增文件,会最终触发调用文件系统的新增接口。文件系统的新增接口不但能够将新增文件添加到终端设备的存储器中,而且还能够判断新增文件是否为媒体文件。若判断出新增文件是媒体文件,则将文件新增的消息上报给文件系统的守护进程,经由守护进程将文件新增的消息上报给“媒体文件扫描服务”。“媒体文件扫描服务”调用“文件解析服务”解析该新增文件。然后,“文件解析服务”将文件解析得到的文件相关属性信息添加到媒体数据库中。Exemplarily, adding a file through a third-party APP will eventually trigger a call to a new interface of the file system. The newly added interface of the file system can not only add the newly added file to the storage of the terminal device, but also can judge whether the newly added file is a media file. If it is determined that the newly added file is a media file, the message of the newly added file is reported to the daemon process of the file system, and the message of the newly added file is reported to the "media file scanning service" through the daemon process. The "media file scanning service" calls the "file parsing service" to parse the newly added file. Then, the "file parsing service" adds the file-related attribute information obtained by parsing the file into the media database.
方式二,若目标文件对应的扫描结果为存储器中的目标文件被删除、且媒体数据库中存在目标文件的属性信息,则终端设备删除媒体数据库中目标文件的属性信息。Manner 2: If the scan result corresponding to the target file is that the target file in the memory is deleted and the attribute information of the target file exists in the media database, the terminal device deletes the attribute information of the target file in the media database.
其中,终端设备可以读取媒体数据库中的所有文件信息,然后检查各个文件是否还存在于存储器中,对于存储器中不存在的文件,从媒体数据库中删除该文件的相关属性信息。具体地,若目标文件已经从存储器被删除,则从媒体数据库中删除该目标文件的相关属性信息。The terminal device can read all file information in the media database, then check whether each file still exists in the memory, and delete the relevant attribute information of the file from the media database for the file that does not exist in the memory. Specifically, if the target file has been deleted from the storage, the relevant attribute information of the target file is deleted from the media database.
示例性的,通过第三方APP删除文件,会最终触发调用文件系统的删除接口。文件系统的删除接口不但能够从终端设备的存储器中删除指定文件,而且还能够判断被删除的文件是否为媒体文件。若判断出被删除的文件是媒体文件,则将文件被删除的消息上报给文件系统的守护进程,经由守护进程将文件被删除的消息上报给“媒体文件扫描服务”。“媒体文件扫描服务”通过对媒体数据库扫描,查找到被删除的文件的相关属性信息。然后,将该被删除的文件的相关属性信息从媒体数据库中删除。Exemplarily, deleting a file through a third-party APP will eventually trigger calling a delete interface of the file system. The deletion interface of the file system can not only delete the specified file from the storage of the terminal device, but also judge whether the deleted file is a media file. If it is determined that the deleted file is a media file, the file deletion message is reported to the daemon process of the file system, and the file deletion message is reported to the "media file scanning service" through the daemon process. "Media file scanning service" finds the relevant attribute information of deleted files by scanning the media database. Then, the relevant attribute information of the deleted file is deleted from the media database.
方式三,若目标文件对应的扫描结果为存储器中的目标文件被修改、且媒体数据库中存在修改前的目标文件的属性信息,则终端设备获取修改后的目标文件的属性信息,并将媒体数据库中修改前的目标文件的属性信息替换为修改后的目标文件的属性信息。Mode 3: If the scan result corresponding to the target file is that the target file in the memory is modified and the attribute information of the target file before the modification exists in the media database, the terminal device obtains the attribute information of the modified target file, and uses the media database to obtain the attribute information of the modified target file. Replace the attribute information of the target file before modification with the attribute information of the modified target file.
其中,终端设备可以启动媒体文件扫描服务进程进行扫描,查找到修改后的目标文件,并查询媒体数据库中是否存在该目标文件的相关属性信息,若存在,则对比实际媒体文件的修改时间与媒体数据库的修改时间是否一致;若不一致,说明修改后未更新,则启动文件解析服务进程对修改后的目标文件进行解析,得到修改后的目标文件的属性信息(即最新文件属性信息)。进一步的,将媒体数据库中的文件属性信息替换为最新文件属性信息,从而实现媒体数据库的实时更新。The terminal device can start the media file scanning service process to scan, find the modified target file, and query whether the relevant attribute information of the target file exists in the media database, and if so, compare the modification time of the actual media file with the media Check whether the modification time of the database is consistent; if it is inconsistent, it means that it has not been updated after modification, then start the file parsing service process to parse the modified target file, and obtain the attribute information of the modified target file (that is, the latest file attribute information). Further, the file attribute information in the media database is replaced with the latest file attribute information, thereby realizing real-time update of the media database.
示例性的,通过第三方APP修改文件,会最终触发调用文件系统的修改接口。文件系统的修改接口不但能够将存储器中的对应文件替换为修改后的文件,而且还能够判断被修改的文件是否为媒体文件。若判断出被修改的文件是媒体文件,则将文件被修改的消息上报给文件系统的守护进程,经由守护进程将文件被修改的消息上报给“媒体文件扫描服务”。“媒体文件扫描服务”调用“文件解析服务”解析该被修改的文件。然后,“文件解析服务”将文件解析得到的文件相关属性信息更新到媒体数据库中。Exemplarily, modifying a file through a third-party APP will eventually trigger calling a modification interface of the file system. The modification interface of the file system can not only replace the corresponding file in the storage with the modified file, but also can judge whether the modified file is a media file. If it is determined that the modified file is a media file, the file modified message is reported to the daemon process of the file system, and the file modified message is reported to the "media file scanning service" through the daemon process. The "media file scanning service" calls the "file parsing service" to parse the modified file. Then, the "file parsing service" updates the file-related attribute information obtained by parsing the file into the media database.
下面再结合图4以更直观的方式理解本申请实施例提供的媒体数据处理方法的架构示意图。如图4所示,终端设备可以响应于用户通过第三方APP对目标文件的增删改查文件操作,向文件系统发送针对目标文件的处理请求。一方面,文件系统按照处理请求指示的处理方式对目标文件进行处理;另一方面,文件系统根据处理请求,调用对应接口来判断目标文件是否为媒体文件。若目标文件为媒体类型的文件,则经由文件系统的“文件守护进程”(vold)向“媒体文件扫描服务”上报消息,指示执行文件扫描。然后,触发媒体文件扫描服务进程启动,执行文件扫描并进行文件解析,得到目标文件对应的扫描结果,并调用“媒体提供”,根据目标文件对应的扫描结果,在媒体数据库中更新目标文件的属性信息。如此,本申请实施例通过文件系统上报机制,触发文件扫描,以将媒体数据库中的媒体文件信息与实际媒体文件进行实时同步,保证终端设备中媒体文件信息的一致性。In the following, the schematic diagram of the architecture of the media data processing method provided by the embodiment of the present application can be understood in a more intuitive manner with reference to FIG. 4 . As shown in FIG. 4 , the terminal device may send a processing request for the target file to the file system in response to the user's operation of adding, deleting, modifying, and checking the target file through the third-party APP. On the one hand, the file system processes the target file according to the processing method indicated by the processing request; on the other hand, the file system calls the corresponding interface to determine whether the target file is a media file according to the processing request. If the target file is a media type file, a message is reported to the "Media File Scanning Service" via the "file daemon" (vold) of the file system, instructing to perform file scanning. Then, trigger the media file scanning service process to start, perform file scanning and file analysis, obtain the scanning result corresponding to the target file, and call "media provision", and update the attribute of the target file in the media database according to the scanning result corresponding to the target file information. In this way, the embodiment of the present application triggers file scanning through the file system reporting mechanism, so as to synchronize the media file information in the media database with the actual media file in real time, and ensure the consistency of the media file information in the terminal device.
通过上述方案,可以基于文件系统上报机制,实现当媒体文件被第三方APP修改后,媒体数据库中的媒体文件属性信息与实际媒体文件实时同步,保证媒体文件信息的一致性,提升用户体验。Through the above solution, based on the file system reporting mechanism, when a media file is modified by a third-party APP, the media file attribute information in the media database can be synchronized with the actual media file in real time, ensuring the consistency of media file information and improving user experience.
需要说明的是,在上述实施例中是以终端设备为执行主体进行示例性说明的,在实际实现时,执行主体具体可以是终端设备中的中央处理器(central processing unit,CPU)。具体到本方案,在终端设备中的CPU接收到第一应用发送的针对目标文件的处理请求之后,CPU调用文件系统的第一接口,按照处理请求指示的处理方式对目标文件进行处理;然后,CPU调用文件系统的第二接口,判断目标文件是否为媒体类型的文件;进一步的,若目标文件为媒体类型的文件,则执行文件扫描,得到目标文件对应的扫描结果;然后,CPU根据目标文件对应的扫描结果,在媒体数据库中更新目标文件的属性信息。It should be noted that, in the above embodiments, the terminal device is used as the execution subject for exemplary description, and in actual implementation, the execution subject may specifically be a central processing unit (central processing unit, CPU) in the terminal device. Specifically in this solution, after the CPU in the terminal device receives the processing request for the target file sent by the first application, the CPU calls the first interface of the file system to process the target file according to the processing method indicated by the processing request; then, The CPU invokes the second interface of the file system to determine whether the target file is a media type file; further, if the target file is a media type file, execute file scanning to obtain a scan result corresponding to the target file; The attribute information of the target file is updated in the media database corresponding to the scanning result.
还需要说明的是,在上述实施例中是以第一应用为本终端设备中的应用为例进行说明的,可以理解,本申请实施例不限于此,例如上述第一应用还可以是其他终端设备中的应用,在此情况下,本终端设备和其他终端设备可以是建立互信授权的两个设备,其中一个作为主控设备,另一个作为受控设备。通过本申请提供的方案,可以通过主控设备的第一应用对媒体文件进行操作,触发受控设备执行媒体文件的增删改查操作以及媒体数据库的更新操作,实现媒体数据库中的媒体文件属性信息与实际媒体文件实时同步。具体可以根据实际使用情况确定,本申请实施例不作限定。It should also be noted that, in the above embodiment, the first application is an application in the terminal device as an example for description. It can be understood that the embodiment of the present application is not limited to this, for example, the above first application may also be other terminals An application in a device, in this case, the terminal device and other terminal devices may be two devices that establish mutual trust authorization, one of which is the master device and the other is the controlled device. With the solution provided in this application, the first application of the master control device can operate the media file, trigger the controlled device to perform the operation of adding, deleting, modifying and checking the media file and the updating operation of the media database, so as to realize the attribute information of the media file in the media database. Real-time synchronization with actual media files. Specifically, it can be determined according to the actual use situation, which is not limited in the embodiment of the present application.
本申请实施例提供的媒体数据处理方法,当接收到第一应用发送的针对目标文件的处理请求时,调用终端设备的文件系统的第一接口,按照处理请求指示的处理方式对目标文件进行处理;若目标文件为媒体类型的文件,则执行文件扫描,得到目标文件对应的扫描结果;根据目标文件对应的扫描结果,在终端设备的媒体数据库中更新目标文件的属性信息。通过该方案,在文件系统中增加了判断目标文件是否为媒体文件这一接口,在通过APP操作使得终端设备中的实际文件发生变化(例如新增、删除或修改)时,可以通过文件系统的接口,按照处理请求指示的处理方式对目标文件进行处理,并判断发生变化的文件是否为媒体文件,若为媒体文件,则触发文件扫描,将媒体数据库中的媒体文件信息与实际媒体文件进行实时同步,保证媒体文件信息的一致性和完整性。In the media data processing method provided by the embodiment of the present application, when a processing request for a target file sent by a first application is received, the first interface of the file system of the terminal device is invoked, and the target file is processed according to the processing method indicated by the processing request. ; If the target file is a media type file, perform file scanning to obtain the scanning result corresponding to the target file; update the attribute information of the target file in the media database of the terminal device according to the scanning result corresponding to the target file. Through this solution, an interface for judging whether the target file is a media file is added to the file system. When the actual file in the terminal device changes (such as adding, deleting, or modifying) through the APP operation, the file system can The interface processes the target file according to the processing method indicated by the processing request, and judges whether the changed file is a media file. Synchronization ensures the consistency and integrity of media file information.
可选的,在本申请实施例中,终端设备中还可以配置有与媒体数据库关联的文件显示APP。该文件显示APP可以根据媒体数据库中文件的属性信息,显示文件的缩略图,也就是说,文件显示APP在显示图像时依赖于媒体数据库中记录的文件属性信息。需要说明的是,在终端设备中的实际文件发生变化时,相应地媒体数据库中文件的属性信息需要同步更新,进而文件显示APP可以根据媒体数据库中文件的更新后的属性信息,实时更新显示文件的缩略图,使得在用户通过文件显示APP浏览图像时,可以为用户实时快速地展示终端设备中存储的各个图像。Optionally, in this embodiment of the present application, the terminal device may also be configured with a file display APP associated with the media database. The file display APP can display the thumbnail of the file according to the attribute information of the file in the media database, that is, the file display APP relies on the file attribute information recorded in the media database when displaying the image. It should be noted that when the actual file in the terminal device changes, the attribute information of the file in the media database needs to be updated synchronously, and the file display APP can update the display file in real time according to the updated attribute information of the file in the media database. so that when the user browses images through the file display APP, each image stored in the terminal device can be displayed quickly and in real time for the user.
示例性的,结合图3,如图5所示,在上述S140之后,本申请实施例还可以包括下述的S150。Exemplarily, with reference to FIG. 3 , as shown in FIG. 5 , after the foregoing S140 , the embodiment of the present application may further include the following S150 .
S150,终端设备根据媒体数据库中目标文件的更新后的属性信息,更新文件显示APP中目标文件的显示状态。S150, the terminal device updates the display state of the target file in the APP according to the updated attribute information of the target file in the media database.
其中,上述更新文件显示APP中目标文件的显示状态可以指:在文件显示APP中目标文件被显示(对应于文件新增的情况),或者在文件显示APP中不再被显示(对应于文件被删除的情况),或者在文件显示APP中目标文件的显示内容或位置有变化(对应于文件被修改的情况)。Wherein, the display state of the target file in the above-mentioned update file display APP may refer to: the target file is displayed in the file display APP (corresponding to the case where the file is newly added), or is no longer displayed in the file display APP (corresponding to the file being deleted), or the displayed content or position of the target file in the file display APP has changed (corresponding to the case of the file being modified).
在一些实施例中,若目标文件为图像文件(例如图片或视频),则上述文件显示APP可以为系统预置的图库或相册APP,也可以为具有图像采集及显示功能且能够访问图像文件的第三方APP,以下将这两类APP统称为图库。为了便于说明,以下以图库为例进行示例性地说明。示例性的,在图库的用户操作界面中可以显示图片显示列表,该列表中可以显示有图片或视频对应的缩略图,该列表中的图片或视频可以按照生成时间或修改时间依次排列显示。In some embodiments, if the target file is an image file (such as a picture or a video), the above-mentioned file display APP may be a gallery or photo album APP preset by the system, or may be an APP that has image capture and display functions and can access image files. Third-party APPs, the following two types of APPs are collectively referred to as galleries. For the convenience of description, the following takes a gallery as an example for illustrative description. Exemplarily, a picture display list may be displayed in the user operation interface of the gallery, and thumbnail images corresponding to the pictures or videos may be displayed in the list, and the pictures or videos in the list may be displayed in sequence according to the generation time or the modification time.
在另一些实施例中,若目标文件为音频文件,则上述文件显示APP可以为系统预置的音乐播放APP,也可以为具有音乐播放功能且能够访问音频文件的第三方APP,以下将这两类APP统称为音频播放器。示例性的,在音乐播放APP的用户操作界面中可以显示曲目列表,该列表中可以显示有各个音频文件对应的曲目内容,例如名称、大小、类型和/或封面缩略图等。In other embodiments, if the target file is an audio file, the above-mentioned file display APP may be a music playback APP preset by the system, or may be a third-party APP that has a music playback function and can access audio files. Such APPs are collectively referred to as audio players. Exemplarily, a track list may be displayed in the user operation interface of the music playing APP, and the track content corresponding to each audio file may be displayed in the list, such as name, size, type and/or cover thumbnail.
需要说明的是,在媒体数据库中可以存储图像文件对应的缩略图或者音频文件对应的曲目内容,这些文件实际存储在存储器中。图库可以调用媒体数据库中存储的缩略图,显示实际文件的缩略图。通过缩略图的显示形式,用户可以直观地浏览图库中的大量图片或视频。若用户需要查看某一图像,则用户可以点击缩略图,触发终端设备显示该缩略图对应的原始图像。可以理解,与对应的原始图像相比,缩略图的分辨率相对较低,占用空间内存较小。It should be noted that, thumbnail images corresponding to image files or content of tracks corresponding to audio files may be stored in the media database, and these files are actually stored in the memory. The gallery can call up the thumbnails stored in the media database to display thumbnails of the actual files. Through the display of thumbnails, users can intuitively browse a large number of pictures or videos in the gallery. If the user needs to view a certain image, the user can click on the thumbnail to trigger the terminal device to display the original image corresponding to the thumbnail. It can be understood that the resolution of the thumbnail is relatively low and takes up less space and memory than the corresponding original image.
可选的,假设目标文件为图像文件,上述S150具体可以包括如下三种可能实现方式:Optionally, assuming that the target file is an image file, the above S150 may specifically include the following three possible implementation manners:
方式一,若媒体数据库中新增了图像文件的属性信息,则在图库中新增显示图像文件对应的缩略图。Manner 1: If the attribute information of the image file is newly added in the media database, the thumbnail image corresponding to the image file is newly displayed in the gallery.
示例性的,用户通过第三方APP(例如即时社交软件)的拍摄入口或相册入口生成一张照片,终端设备可以响应于用户的该操作,将生成的照片存储于存储器中,并在媒体数据库中添加该照片的属性信息,相应地会在图库中添加显示该照片对应的缩 略图。这样,当用户通过图库浏览图像时,图库会刷新并展示出新增照片的缩略图。如此实现媒体数据库中的记录、图库中的图片显示列表与实际图像文件实时同步,避免了终端设备由于图像文件信息未同步而导致新增的图像文件无法及时展示给用户的问题,提升用户体验。Exemplarily, the user generates a photo through the shooting portal or album portal of a third-party APP (such as instant social software), and the terminal device can respond to the user's operation, and store the generated photo in the memory and in the media database. Add the attribute information of the photo, and correspondingly, the thumbnail corresponding to the photo will be added to the gallery. This way, when a user browses images through the gallery, the gallery refreshes to show thumbnails of the newly added photos. In this way, the records in the media database and the picture display list in the gallery are synchronized with the actual image file in real time, which avoids the problem that the newly added image file cannot be displayed to the user in time due to the unsynchronized image file information of the terminal device, and improves the user experience.
方式二,若媒体数据库中删除了图像文件的属性信息,则在图库中取消显示图像文件对应的缩略图。In the second way, if the attribute information of the image file is deleted from the media database, the thumbnail image corresponding to the image file is canceled from being displayed in the gallery.
示例性的,用户通过第三方APP(例如即时社交软件)的相册入口查看手机中的照片并选中其中一张照片进行删除操作,终端设备可以响应于用户的该操作,将用户选中的该照片从存储器中删除,并在媒体数据库中删除该照片的属性信息,相应地会在图库中不再显示该照片对应的缩略图。这样,当用户通过图库浏览图片或视频时,图库会刷新并不再展示被删除图片的缩略图。如此实现媒体数据库中的记录、图库中的图片显示列表与实际图像文件实时同步,避免了已被删除的图像还仍然被展示给用户的问题,提升用户体验。Exemplarily, the user views the photos in the mobile phone through the album portal of the third-party APP (for example, instant social software) and selects one of the photos to delete, and the terminal device can respond to the user's operation and delete the photo selected by the user from the photo album. It is deleted from the storage, and the attribute information of the photo is deleted in the media database, and correspondingly, the thumbnail corresponding to the photo will no longer be displayed in the gallery. In this way, when a user browses pictures or videos through the gallery, the gallery refreshes and no longer displays thumbnails of deleted images. In this way, the records in the media database and the picture display list in the gallery are synchronized with the actual image file in real time, which avoids the problem that deleted images are still displayed to the user, and improves the user experience.
方式三,若媒体数据库中更新了图像文件的属性信息,则在图库中更新显示图像文件对应的缩略图。In the third method, if the attribute information of the image file is updated in the media database, the thumbnail image corresponding to the image file is updated and displayed in the gallery.
示例性的,用户通过第三方APP(例如图片处理软件)查看照片并对该照片进行修图,终端设备响应于用户的该操作,将修图后的照片存储于存储器中,并在媒体数据库中更新该照片的属性信息,相应地会在图库中更新显示该照片对应的缩略图。这样,当用户通过图库浏览图像时,图库会刷新并展示出修图后的照片的缩略图。如此实现媒体数据库中的记录、图库中的图片显示列表与实际图像文件实时同步。Exemplarily, the user views the photo through a third-party APP (such as image processing software) and retouches the photo, and the terminal device responds to the user's operation and stores the retouched photo in the memory and in the media database. When the attribute information of the photo is updated, the corresponding thumbnail of the photo will be updated and displayed in the gallery accordingly. This way, when a user browses images through the gallery, the gallery refreshes and displays thumbnails of the retouched photos. In this way, the records in the media database and the picture display list in the gallery are synchronized with the actual image files in real time.
需要说明的是,上述方式三中所提到的在图库中更新显示目标文件对应的缩略图可以指更新目标文件对应的缩略图的显示内容,或者更新目标文件对应的缩略图的显示位置,还可以是指其他可能的更新显示,具体可以根据实际使用情况确定,本申请实施例不作限定。It should be noted that updating the thumbnail image corresponding to the target file in the gallery mentioned in the third method may refer to updating the display content of the thumbnail image corresponding to the target file, or updating the display position of the thumbnail image corresponding to the target file, or updating the thumbnail image corresponding to the target file. It may refer to other possible update displays, which may be specifically determined according to actual usage conditions, which are not limited in this embodiment of the present application.
通过上述三种方式,可以实现当图像文件被第三方APP操作处理后,媒体数据库中的记录、图库中的图片显示列表与实际图像文件实时同步,如此可以保证终端设备中图像文件信息的一致性。这样,图库可以通过调用媒体数据库中实时更新的媒体文件信息,为用户实时快速地展示已存储图像,提升用户体验。Through the above three methods, after the image file is processed by the third-party APP, the records in the media database and the picture display list in the gallery can be synchronized with the actual image file in real time, which can ensure the consistency of the image file information in the terminal device. . In this way, the gallery can quickly display the stored images for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
可选的,假设目标文件为音频文件,上述S150具体可以包括如下三种可能实现方式:Optionally, assuming that the target file is an audio file, the above S150 may specifically include the following three possible implementations:
方式一,若媒体数据库中新增了音频文件的属性信息,则在音频播放器中新增显示音频文件对应的曲目内容。Manner 1: If the attribute information of the audio file is newly added in the media database, the content of the track corresponding to the audio file is newly displayed in the audio player.
示例性的,用户通过第三方APP(例如音乐播放软件)查看某个歌手的音乐专辑并下载音乐专辑中的某些歌曲,终端设备可以响应于用户的该操作,将下载的歌曲存储于存储器中,并在媒体数据库中添加该下载的歌曲对应的属性信息,相应地会在终端设备的音频播放器中添加显示该歌曲对应的曲目内容。如此实现媒体数据库中的记录、音频播放器中的曲目列表与实际音频文件实时同步。Exemplarily, a user views a certain singer's music album and downloads some songs in the music album through a third-party APP (such as music playing software), and the terminal device can respond to the user's operation and store the downloaded songs in the memory. , and add attribute information corresponding to the downloaded song in the media database, and correspondingly add and display the content of the song corresponding to the song in the audio player of the terminal device. In this way, the recording in the media database, the track list in the audio player and the actual audio file are synchronized in real time.
方式二,若媒体数据库中删除了音频文件的属性信息,则在音频播放器中取消显示音频文件对应的曲目内容。In a second way, if the attribute information of the audio file is deleted from the media database, the content of the track corresponding to the audio file is canceled in the audio player.
示例性的,用户通过第三方APP(例如音乐播放软件)查看自己已经下载的歌曲并选中其中一个歌曲进行删除操作,终端设备可以响应于用户的该操作,将用户选中的该歌曲从存储器中删除,并在媒体数据库中删除该歌曲对应的属性信息,相应地在终端设备的音频播放器中不再显示该歌曲对应的曲目内容。如此实现媒体数据库中的记录、音频播放器中的曲目列表与实际音频文件实时同步。Exemplarily, the user views the songs he has downloaded through a third-party APP (such as music playing software) and selects one of the songs to delete, and the terminal device can respond to the user's operation and delete the song selected by the user from the memory. , and delete the attribute information corresponding to the song in the media database, and correspondingly, the content of the track corresponding to the song is no longer displayed in the audio player of the terminal device. In this way, the recording in the media database, the track list in the audio player and the actual audio file are synchronized in real time.
方式三,若媒体数据库中更新了音频文件的属性信息,则在音频播放器中更新显示音频文件对应的曲目内容。In the third method, if the attribute information of the audio file is updated in the media database, the content of the track corresponding to the audio file is updated and displayed in the audio player.
示例性的,用户通过第三方APP(例如音乐播放软件)查看自己已经下载的歌曲并选中其中一个歌曲进行收藏操作,终端设备响应于用户的该操作,在媒体数据库中更新该歌曲的属性信息,即针对该歌曲添加收藏标签,相应地会在音频播放器中更新显示该歌曲对应的曲目内容。如此实现媒体数据库中的记录、音频播放器中的曲目列表与实际音频文件实时同步。Exemplarily, the user checks the songs he has downloaded through a third-party APP (such as music playing software) and selects one of the songs to perform a collection operation, and the terminal device updates the attribute information of the song in the media database in response to the user's operation, That is, adding a favorite tag to the song will update and display the content of the track corresponding to the song in the audio player accordingly. In this way, the recording in the media database, the track list in the audio player and the actual audio file are synchronized in real time.
通过上述三种方式,可以实现当音频文件被第三方APP操作处理后,媒体数据库中的记录、音频播放器中的曲目列表与实际音频文件实时同步,如此可以保证终端设备中音频文件信息的一致性。这样,音频播放器可以通过调用媒体数据库中实时更新的媒体文件信息,为用户实时快速地展示已存储音频文件,提升用户体验。Through the above three methods, after the audio file is processed by the third-party APP, the records in the media database and the track list in the audio player can be synchronized with the actual audio file in real time, which can ensure the consistency of the audio file information in the terminal device. sex. In this way, the audio player can quickly display the stored audio files for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
下面以通过手机中安装的第三方APP新增图片的场景为例,对上述实施例进行示例性说明。手机中预置的系统APP(例如相机APP)可以生成、删除或修改媒体文件(例如图片或视频);或者,手机中安装的第三方APP(例如即时通讯软件)也可以生成、删除或修改媒体文件(例如图片或视频)。当用户使用系统APP或第三方APP产生了一张图片(例如通过相机拍摄得到图片或者从网络下载图片),会触发文件系统监听到手机存储卡中新增了一个文件,此时首先判断该文件是否为媒体文件,若该文件是媒体文件,则将该文件信息上报给文件守护进程,文件守护进程继续上报给媒体文件扫描服务,触发媒体文件扫描服务启动,执行文件扫描,并调用“文件解析服务”解析该文件,最终将解析的结果插入到媒体数据库中。在此情况下,当图库监听到媒体数据库中有新增图片时,图库会刷新并展示出该新增图片的缩略图。如此,可以实现在通过第三方APP保存图片后,媒体数据库能够及时更新,使得媒体数据库与实际文件实时同步,最终能够保证图库能够及时展示手机中保存的图片。The foregoing embodiment is exemplarily described below by taking a scenario of adding a picture through a third-party APP installed in a mobile phone as an example. The system APP (such as camera APP) preset in the mobile phone can generate, delete or modify media files (such as pictures or videos); or, the third-party APP (such as instant messaging software) installed in the mobile phone can also generate, delete or modify media files files (such as pictures or videos). When the user uses the system APP or a third-party APP to generate a picture (for example, the picture is captured by the camera or downloaded from the network), the file system will be triggered to monitor that a new file has been added to the mobile phone memory card. At this time, the file is first determined. Whether it is a media file, if the file is a media file, the file information will be reported to the file daemon, and the file daemon will continue to report it to the media file scanning service, trigger the media file scanning service to start, perform file scanning, and call "file parsing". service" parses the file and finally inserts the parsed result into the media database. In this case, when the gallery monitors that there is a new image in the media database, the gallery will refresh and display the thumbnail of the newly added image. In this way, after the pictures are saved through the third-party APP, the media database can be updated in time, so that the media database can be synchronized with the actual files in real time, and finally the gallery can display the pictures saved in the mobile phone in time.
通过本申请提供的方案,在终端设备中的实际文件发生变化时,相应地同步更新媒体数据库中文件的属性信息,进而文件显示APP可以根据媒体数据库中文件的更新后的属性信息,实时更新显示文件的缩略图,这样在用户通过文件显示APP浏览图像时,可以为用户实时快速地展示终端设备中存储的各个图像,避免了终端设备无法及时将新增的媒体文件展示给用户或者是已被删除的文件还仍然被展示给用户的问题,提升用户体验。Through the solution provided by the present application, when the actual file in the terminal device changes, the attribute information of the file in the media database is correspondingly updated synchronously, and the file display APP can update the display in real time according to the updated attribute information of the file in the media database. The thumbnail of the file, so that when the user browses images through the file display APP, each image stored in the terminal device can be displayed quickly and in real time for the user, so that the terminal device cannot display the newly added media files to the user in time or has been Deleted files are also still displayed to the user, improving the user experience.
本文中描述的各个实施例可以为独立的方案,也可以根据内在逻辑进行组合,这些方案都落入本申请的保护范围中。The various embodiments described herein may be independent solutions, or may be combined according to internal logic, and these solutions all fall within the protection scope of the present application.
可以理解的是,上述各个方法实施例中由终端设备实现的方法和操作,也可以由可用于终端设备的部件(例如芯片或者电路)实现。It can be understood that, the methods and operations implemented by the terminal device in the foregoing method embodiments may also be implemented by components (for example, chips or circuits) that can be used in the terminal device.
上文描述了本申请提供的方法实施例,下文将描述本申请提供的装置实施例。应 理解,装置实施例的描述与方法实施例的描述相互对应,因此,未详细描述的内容可以参见上文方法实施例,为了简洁,这里不再赘述。The method embodiments provided by the present application are described above, and the device embodiments provided by the present application will be described below. It should be understood that the description of the apparatus embodiment corresponds to the description of the method embodiment. Therefore, for the content that is not described in detail, reference may be made to the above method embodiment, which is not repeated here for brevity.
上文主要从方法步骤的角度对本申请实施例提供的方案进行了描述。可以理解的是,为了实现上述功能,实施该方法的终端设备包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的保护范围。The solutions provided by the embodiments of the present application have been described above mainly from the perspective of method steps. It can be understood that, in order to realize the above functions, the terminal device implementing the method includes corresponding hardware structures and/or software modules for executing each function. Those skilled in the art should realize that the present application can be implemented in hardware or a combination of hardware and computer software with the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein. Whether a function is performed by hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may use different methods to implement the described functions for each particular application, but such implementations should not be considered outside the scope of protection of this application.
本申请实施例可以根据上述方法示例,对终端设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有其它可行的划分方式。下面以采用对应各个功能划分各个功能模块为例进行说明。In the embodiments of the present application, the terminal device may be divided into functional modules according to the foregoing method examples. For example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules. It should be noted that the division of modules in the embodiments of the present application is illustrative, and is only a logical function division, and other feasible division manners may be used in actual implementation. The following description will be given by taking as an example that each function module is divided corresponding to each function.
图6为本申请实施例提供的媒体数据处理装置800的示意性框图。该装置800可以用于执行上文方法实施例中终端设备所执行的动作。该装置800包括处理单元810和扫描单元820。FIG. 6 is a schematic block diagram of a media data processing apparatus 800 according to an embodiment of the present application. The apparatus 800 may be used to perform the actions performed by the terminal device in the above method embodiments. The apparatus 800 includes a processing unit 810 and a scanning unit 820 .
处理单元810,用于当接收到第一应用发送的针对目标文件的处理请求时,调用装置800的文件系统的第一接口,按照处理请求指示的处理方式对目标文件进行处理。The processing unit 810 is configured to, when receiving a processing request for the target file sent by the first application, call the first interface of the file system of the apparatus 800 to process the target file according to the processing mode indicated by the processing request.
扫描单元820,用于若目标文件为媒体类型的文件,则执行文件扫描,得到目标文件对应的扫描结果。The scanning unit 820 is configured to perform file scanning if the target file is a media type file to obtain a scanning result corresponding to the target file.
处理单元810,还用于根据目标文件对应的扫描结果,在装置800的媒体数据库中更新目标文件的属性信息。The processing unit 810 is further configured to update the attribute information of the target file in the media database of the device 800 according to the scanning result corresponding to the target file.
在一些实施例中,上述目标文件的属性信息包括以下至少一项:目标文件的存储路径信息、目标文件的名称信息、目标文件的文件大小信息、目标文件的文件类型信息、目标文件的最后修改时间信息。In some embodiments, the attribute information of the target file includes at least one of the following: storage path information of the target file, name information of the target file, file size information of the target file, file type information of the target file, last modification of the target file time information.
在一些实施例中,处理单元810还用于调用文件系统的第二接口,判断目标文件是否为媒体类型的文件。In some embodiments, the processing unit 810 is further configured to call a second interface of the file system to determine whether the target file is a media type file.
在一些实施例中,处理单元810还用于经由文件系统的守护进程向扫描单元820上报第一消息,该第一消息用于指示执行文件扫描。进一步的,扫描单元820具体用于根据该第一消息,启动媒体文件扫描服务进程,执行媒体文件扫描。In some embodiments, the processing unit 810 is further configured to report a first message to the scanning unit 820 via a daemon process of the file system, where the first message is used to instruct to perform file scanning. Further, the scanning unit 820 is specifically configured to start the media file scanning service process according to the first message, and perform media file scanning.
在一些实施例中,处理单元810具体用于:In some embodiments, the processing unit 810 is specifically configured to:
若处理请求用于指示新增目标文件,则调用文件系统的新增接口,在装置800的存储器中存储目标文件;If the processing request is used to instruct to add a new target file, the new interface of the file system is called to store the target file in the memory of the device 800;
或者,若处理请求用于指示删除目标文件,则调用文件系统的删除接口,删除存储器中存储的目标文件;Or, if the processing request is used to instruct to delete the target file, the delete interface of the file system is called to delete the target file stored in the memory;
或者,若处理请求用于指示修改目标文件,则调用文件系统的修改接口,修改目标文件,并将存储器中存储的目标文件更新为修改后的目标文件。Or, if the processing request is used to instruct to modify the target file, the modification interface of the file system is invoked, the target file is modified, and the target file stored in the memory is updated to the modified target file.
在一些实施例中,处理单元810具体用于:In some embodiments, the processing unit 810 is specifically configured to:
若目标文件对应的扫描结果为目标文件被新增到装置800的存储器中、且媒体数据库中不存在目标文件的属性信息,则获取目标文件的属性信息,并在媒体数据库中新增目标文件的属性信息;If the scanning result corresponding to the target file is that the target file is newly added to the memory of the device 800 and the attribute information of the target file does not exist in the media database, the attribute information of the target file is acquired, and the attribute information of the target file is added to the media database. attribute information;
或者,若目标文件对应的扫描结果为存储器中的目标文件被删除、且媒体数据库中存在目标文件的属性信息,则删除媒体数据库中目标文件的属性信息;Or, if the scanning result corresponding to the target file is that the target file in the memory is deleted, and the attribute information of the target file exists in the media database, then delete the attribute information of the target file in the media database;
或者,若目标文件对应的扫描结果为存储器中的目标文件被修改、且媒体数据库中存在修改前的目标文件的属性信息,则获取修改后的目标文件的属性信息,并将媒体数据库中修改前的目标文件的属性信息替换为修改后的目标文件的属性信息。Or, if the scan result corresponding to the target file is that the target file in the memory is modified and the attribute information of the target file before the modification exists in the media database, then the attribute information of the modified target file is obtained, and the pre-modification information in the media database is obtained. The attribute information of the target file is replaced with the attribute information of the modified target file.
在一些实施例中,处理单元810具体用于:In some embodiments, the processing unit 810 is specifically configured to:
通过文件解析服务进程对新增的目标文件进行解析,得到目标文件的属性信息;The newly added target file is parsed through the file parsing service process, and the attribute information of the target file is obtained;
或者,通过文件解析服务进程对修改后的目标文件进行解析,得到修改后的目标文件的属性信息。Alternatively, the modified target file is parsed through the file analysis service process to obtain attribute information of the modified target file.
在一些实施例中,处理单元810还用于在媒体数据库中更新目标文件的属性信息之后,根据媒体数据库中目标文件的更新后的属性信息,更新装置800的文件显示应用中目标文件的显示状态。In some embodiments, the processing unit 810 is further configured to, after updating the attribute information of the target file in the media database, update the display state of the target file in the file display application of the device 800 according to the updated attribute information of the target file in the media database .
在一些实施例中,处理单元810具体用于:In some embodiments, the processing unit 810 is specifically configured to:
若媒体数据库中新增了目标文件的属性信息,则在文件显示应用中新增显示目标文件对应的缩略图;If the attribute information of the target file is newly added in the media database, the thumbnail corresponding to the target file is newly displayed in the file display application;
或者,若媒体数据库中删除了目标文件的属性信息,则在文件显示应用中取消显示目标文件对应的缩略图;Or, if the attribute information of the target file is deleted from the media database, the thumbnail image corresponding to the target file is canceled in the file display application;
或者,若媒体数据库中更新了目标文件的属性信息,则在文件显示应用中更新显示目标文件对应的缩略图。Or, if the attribute information of the target file is updated in the media database, the thumbnail image corresponding to the target file is updated and displayed in the file display application.
本申请实施例提供的媒体数据处理装置,在文件系统中增加了判断目标文件是否为媒体文件这一接口,在通过APP操作使得终端设备中的实际文件发生变化(例如新增、删除或修改)时,可以通过文件系统的接口,按照处理请求指示的处理方式对目标文件进行处理,并判断发生变化的文件是否为媒体文件,若为媒体文件,则触发文件扫描,将媒体数据库中的媒体文件信息与实际媒体文件进行实时同步,保证媒体文件信息的一致性和完整性。这样,图库可以通过调用媒体数据库中实时更新的媒体文件信息,为用户实时快速地展示已存储图像,提升用户体验。In the media data processing apparatus provided by the embodiment of the present application, an interface for determining whether the target file is a media file is added to the file system, and the actual file in the terminal device is changed (for example, added, deleted, or modified) through the APP operation. When the file system interface is used, the target file can be processed according to the processing method indicated by the processing request, and whether the changed file is a media file can be judged. The information is synchronized with the actual media file in real time to ensure the consistency and integrity of the media file information. In this way, the gallery can quickly display the stored images for the user in real time by calling the real-time updated media file information in the media database, thereby improving the user experience.
根据本申请实施例的装置800可对应于执行本申请实施例中描述的方法,并且装置800中的单元的上述和其它操作和/或功能分别为了实现方法的相应流程,为了简洁,在此不再赘述。The apparatus 800 according to the embodiments of the present application may correspond to executing the methods described in the embodiments of the present application, and the above-mentioned and other operations and/or functions of the units in the apparatus 800 are respectively to implement the corresponding processes of the methods, and are not described herein for the sake of brevity. Repeat.
图7是本申请实施例提供的终端设备900的结构性示意性图。该终端设备900包括:处理器910、存储器920、通信接口930、总线940。FIG. 7 is a schematic structural diagram of a terminal device 900 provided by an embodiment of the present application. The terminal device 900 includes: a processor 910 , a memory 920 , a communication interface 930 , and a bus 940 .
其中,该处理器910可以与存储器920连接。该存储器920可以用于存储该程序代码和数据。因此,该存储器920可以是处理器910内部的存储单元,也可以是与处理器910独立的外部存储单元,还可以是包括处理器910内部的存储单元和与处理器910独立的外部存储单元的部件。需要说明的是,图7所示的终端设备900中的处理 器910可以对应于图6中的装置800中的处理单元810。Wherein, the processor 910 can be connected with the memory 920 . The memory 920 may be used to store the program codes and data. Therefore, the memory 920 may be a storage unit within the processor 910 , or may be an external storage unit independent of the processor 910 , or may include a storage unit within the processor 910 and an external storage unit independent of the processor 910 . part. It should be noted that, the processor 910 in the terminal device 900 shown in FIG. 7 may correspond to the processing unit 810 in the apparatus 800 in FIG. 6 .
可选的,终端设备900还可以包括总线940。其中,存储器920、通信接口930可以通过总线940与处理器910连接。总线940可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。该总线940可以分为地址总线、数据总线、控制总线等。为便于表示,图7中仅用一条线表示,但并不表示仅有一根总线或一种类型的总线。Optionally, the terminal device 900 may further include a bus 940 . The memory 920 and the communication interface 930 may be connected to the processor 910 through the bus 940 . The bus 940 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus or the like. The bus 940 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one line is shown in FIG. 7, but it does not mean that there is only one bus or one type of bus.
应理解,在本申请实施例中,该处理器910可以采用中央处理单元(central processing unit,CPU)。该处理器还可以是其它通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field programmable gate Array,FPGA)或者其它可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。或者该处理器810采用一个或多个集成电路,用于执行相关程序,以实现本申请实施例所提供的技术方案。It should be understood that, in this embodiment of the present application, the processor 910 may adopt a central processing unit (central processing unit, CPU). The processor may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Alternatively, the processor 810 uses one or more integrated circuits to execute related programs, so as to implement the technical solutions provided by the embodiments of the present application.
该存储器920可以包括只读存储器和随机存取存储器,并向处理器910提供指令和数据。处理器910的一部分还可以包括非易失性随机存取存储器。例如,处理器910还可以存储设备类型的信息。The memory 920 , which may include read-only memory and random access memory, provides instructions and data to the processor 910 . A portion of processor 910 may also include non-volatile random access memory. For example, the processor 910 may also store device type information.
在终端设备900运行时,处理器910执行存储器920中的计算机执行指令以执行上述方法的操作步骤。When the terminal device 900 is running, the processor 910 executes the computer-executed instructions in the memory 920 to perform the operation steps of the above-mentioned method.
应理解,根据本申请实施例的终端设备900可对应于本申请实施例中的装置800,并且装置800中的各个单元的上述和其它操作和/或功能分别为了实现上述方法的相应流程,为了简洁,在此不再赘述。It should be understood that the terminal device 900 according to the embodiment of the present application may correspond to the apparatus 800 in the embodiment of the present application, and the above-mentioned and other operations and/or functions of each unit in the apparatus 800 are to implement the corresponding processes of the above-mentioned methods, respectively, in order to It is concise and will not be repeated here.
可选地,在一些实施例中,本申请实施例还提供了一种计算机可读介质,该计算机可读介质存储有程序代码,当计算机程序代码在计算机上运行时,使得计算机执行上述各方面中的方法。Optionally, in some embodiments, embodiments of the present application further provide a computer-readable medium, where program codes are stored in the computer-readable medium, and when the computer program codes are run on a computer, the computer can execute the above aspects method in .
可选地,在一些实施例中,本申请实施例还提供了一种计算机程序产品,该计算机程序产品包括:计算机程序代码,当计算机程序代码在计算机上运行时,使得计算机执行上述各方面中的方法。Optionally, in some embodiments, the embodiments of the present application further provide a computer program product, the computer program product includes: computer program code, when the computer program code runs on the computer, the computer program code enables the computer to perform the above aspects. Methods.
在本申请实施例中,终端设备或网络设备包括硬件层、运行在硬件层之上的操作系统层,以及运行在操作系统层上的应用层。其中,硬件层可以包括中央处理器(central processing unit,CPU)、内存管理单元(memory management unit,MMU)和内存(也称为主存)等硬件。操作系统层的操作系统可以是任意一种或多种通过进程(process)实现业务处理的计算机操作系统,例如,Linux操作系统、Unix操作系统、Android操作系统、iOS操作系统或windows操作系统等。应用层可以包含浏览器、通讯录、文字处理软件、即时通信软件等应用。In this embodiment of the present application, the terminal device or the network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer may include hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory (also called main memory). The operating system of the operating system layer may be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system. The application layer may include applications such as browsers, address books, word processing software, and instant messaging software.
本申请实施例并未对本申请实施例提供的方法的执行主体的具体结构进行特别限定,只要能够通过运行记录有本申请实施例提供的方法的代码的程序,以根据本申请实施例提供的方法进行通信即可。例如,本申请实施例提供的方法的执行主体可以是终端设备或网络设备,或者,是终端设备或网络设备中能够调用程序并执行程序的功能模块。The embodiments of the present application do not specifically limit the specific structure of the execution body of the methods provided by the embodiments of the present application, as long as the program in which the codes of the methods provided by the embodiments of the present application are recorded can be executed to execute the methods according to the embodiments of the present application. Just communicate. For example, the execution body of the method provided by the embodiment of the present application may be a terminal device or a network device, or a functional module in the terminal device or network device that can call a program and execute the program.
本申请的各个方面或特征可以实现成方法、装置或使用标准编程和/或工程技术的制品。本文中使用的术语“制品”可以涵盖可从任何计算机可读器件、载体或介质访问的计算机程序。例如,计算机可读介质可以包括但不限于:磁存储器件(例如,硬盘、软盘或磁带等),光盘(例如,压缩盘(compact disc,CD)、数字通用盘(digital versatile disc,DVD)等),智能卡和闪存器件(例如,可擦写可编程只读存储器(erasable programmable read-only memory,EPROM)、卡、棒或钥匙驱动器等)。Various aspects or features of the present application may be implemented as methods, apparatus, or articles of manufacture using standard programming and/or engineering techniques. The term "article of manufacture" as used herein may encompass a computer program accessible from any computer-readable device, carrier or media. For example, computer readable media may include, but are not limited to, magnetic storage devices (eg, hard disks, floppy disks, or magnetic tapes, etc.), optical disks (eg, compact discs (CDs), digital versatile discs (DVDs), etc. ), smart cards and flash memory devices (eg, erasable programmable read-only memory (EPROM), cards, stick or key drives, etc.).
本文描述的各种存储介质可代表用于存储信息的一个或多个设备和/或其它机器可读介质。术语“机器可读介质”可以包括但不限于:无线信道和能够存储、包含和/或承载指令和/或数据的各种其它介质。Various storage media described herein may represent one or more devices and/or other machine-readable media for storing information. The term "machine-readable medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing, and/or carrying instructions and/or data.
应理解,本申请实施例中提及的处理器可以是中央处理单元(central processing unit,CPU),还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that the processor mentioned in the embodiments of the present application may be a central processing unit (central processing unit, CPU), and may also be other general-purpose processors, digital signal processors (digital signal processors, DSP), application-specific integrated circuits ( application specific integrated circuit, ASIC), off-the-shelf programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
还应理解,本申请实施例中提及的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM)。例如,RAM可以用作外部高速缓存。作为示例而非限定,RAM可以包括如下多种形式:静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。It should also be understood that the memory mentioned in the embodiments of the present application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically programmable Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory. Volatile memory may be random access memory (RAM). For example, RAM can be used as an external cache. By way of example and not limitation, RAM may include the following forms: static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM) , double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synchlink DRAM, SLDRAM) and Direct memory bus random access memory (direct rambus RAM, DR RAM).
需要说明的是,当处理器为通用处理器、DSP、ASIC、FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件时,存储器(存储模块)可以集成在处理器中。It should be noted that when the processor is a general-purpose processor, DSP, ASIC, FPGA or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components, the memory (storage module) can be integrated in the processor.
还需要说明的是,本文描述的存储器旨在包括但不限于这些和任意其它适合类型的存储器。It should also be noted that the memory described herein is intended to include, but not be limited to, these and any other suitable types of memory.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的保护范围。Those of ordinary skill in the art can realize that the units and steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may use different methods to implement the described functions for each particular application, but such implementations should not be considered outside the scope of protection of this application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。此外,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上,或者说对现有技术做出贡献的部分,或者该技术方案的部分,可以以计算机软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,该计算机软件产品包括若干指令,该指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。前述的存储介质可以包括但不限于:U盘、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。The functions, if implemented in the form of software functional units and sold or used as independent products, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a computer software product, and the computer software product is stored in a storage In the medium, the computer software product includes several instructions, the instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium may include, but is not limited to, various media that can store program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中在本申请的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein in the specification of the application are for the purpose of describing specific embodiments only, and are not intended to limit the application.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited to this. should be covered within the scope of protection of this application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims (21)

  1. 一种媒体数据处理方法,其特征在于,所述方法包括:A media data processing method, characterized in that the method comprises:
    当接收到第一应用发送的针对目标文件的处理请求时,调用终端设备的文件系统的第一接口,按照所述处理请求指示的处理方式对所述目标文件进行处理;When receiving the processing request for the target file sent by the first application, calling the first interface of the file system of the terminal device, and processing the target file according to the processing mode indicated by the processing request;
    若所述目标文件为媒体类型的文件,则执行文件扫描,得到所述目标文件对应的扫描结果;If the target file is a media type file, perform file scanning to obtain a scanning result corresponding to the target file;
    根据所述目标文件对应的扫描结果,在所述终端设备的媒体数据库中更新所述目标文件的属性信息。According to the scanning result corresponding to the target file, the attribute information of the target file is updated in the media database of the terminal device.
  2. 根据权利要求1所述的方法,其特征在于,在所述若所述目标文件为媒体类型的文件,则执行文件扫描之前,所述方法还包括:The method according to claim 1, wherein, before performing the file scanning if the target file is a file of a media type, the method further comprises:
    调用所述文件系统的第二接口,判断所述目标文件是否为媒体类型的文件。The second interface of the file system is called to determine whether the target file is a media type file.
  3. 根据权利要求1或2所述的方法,其特征在于,在所述执行文件扫描之前,所述方法还包括:The method according to claim 1 or 2, characterized in that, before the performing file scanning, the method further comprises:
    经由所述文件系统的守护进程向媒体文件扫描服务上报第一消息,所述第一消息用于指示执行文件扫描;reporting a first message to the media file scanning service via the daemon process of the file system, where the first message is used to instruct to perform file scanning;
    其中,所述执行文件扫描,包括:Wherein, the performing file scanning includes:
    根据所述第一消息,启动媒体文件扫描服务进程,执行媒体文件扫描。According to the first message, the media file scanning service process is started to perform media file scanning.
  4. 根据权利要求1至3中任一项所述的方法,其特征在于,所述当接收到第一应用发送的针对目标文件的处理请求时,调用终端设备的文件系统的第一接口,按照所述处理请求指示的处理方式对目标文件进行处理,包括:The method according to any one of claims 1 to 3, wherein when a processing request for the target file sent by the first application is received, the first interface of the file system of the terminal device is called, according to the The target file is processed in the processing method indicated by the above processing request, including:
    若所述处理请求用于指示新增所述目标文件,则调用所述文件系统的新增接口,在所述终端设备的存储器中存储所述目标文件;或者,If the processing request is used to instruct to add the target file, call the new interface of the file system to store the target file in the memory of the terminal device; or,
    若所述处理请求用于指示删除所述目标文件,则调用所述文件系统的删除接口,删除所述存储器中存储的所述目标文件;或者,If the processing request is used to instruct to delete the target file, call the delete interface of the file system to delete the target file stored in the memory; or,
    若所述处理请求用于指示修改所述目标文件,则调用所述文件系统的修改接口,修改所述目标文件,并将所述存储器中存储的所述目标文件更新为修改后的所述目标文件。If the processing request is used to instruct to modify the target file, call the modification interface of the file system, modify the target file, and update the target file stored in the memory to the modified target file document.
  5. 根据权利要求1至4中任一项所述的方法,其特征在于,所述根据所述目标文件对应的扫描结果,在所述终端设备的媒体数据库中更新所述目标文件的属性信息,包括:The method according to any one of claims 1 to 4, wherein the updating the attribute information of the target file in the media database of the terminal device according to the scanning result corresponding to the target file, comprising: :
    若所述目标文件对应的扫描结果为所述目标文件被新增到所述终端设备的存储器中、且所述媒体数据库中不存在所述目标文件的属性信息,则获取所述目标文件的属性信息,并在所述媒体数据库中新增所述目标文件的属性信息;或者,If the scan result corresponding to the target file is that the target file is newly added to the memory of the terminal device, and the attribute information of the target file does not exist in the media database, acquire the attribute of the target file information, and add the attribute information of the target file in the media database; or,
    若所述目标文件对应的扫描结果为所述存储器中的所述目标文件被删除、且所述媒体数据库中存在所述目标文件的属性信息,则删除所述媒体数据库中所述目标文件的属性信息;或者,If the scan result corresponding to the target file is that the target file in the storage is deleted and the attribute information of the target file exists in the media database, delete the attribute of the target file in the media database information; or,
    若所述目标文件对应的扫描结果为所述存储器中的所述目标文件被修改、且所述媒体数据库中存在修改前的所述目标文件的属性信息,则获取修改后的所述目标文件的属性信息,并将所述媒体数据库中修改前的所述目标文件的属性信息替换为修改后 的所述目标文件的属性信息。If the scan result corresponding to the target file is that the target file in the memory is modified and the media database has attribute information of the target file before modification, obtain the modified target file's attribute information. attribute information, and replace the attribute information of the target file before modification in the media database with the attribute information of the target file after modification.
  6. 根据权利要求5所述的方法,其特征在于,所述获取所述目标文件的属性信息,包括:通过文件解析服务进程对新增的所述目标文件进行解析,得到所述目标文件的属性信息;The method according to claim 5, wherein the acquiring the attribute information of the target file comprises: parsing the newly added target file through a file parsing service process to obtain the attribute information of the target file ;
    所述获取修改后的所述目标文件的属性信息,包括:通过所述文件解析服务进程对修改后的所述目标文件进行解析,得到修改后的所述目标文件的属性信息。The acquiring the attribute information of the modified target file includes: parsing the modified target file through the file parsing service process to obtain the modified attribute information of the target file.
  7. 根据权利要求1至6中任一项所述的方法,其特征在于,在所述媒体数据库中更新所述目标文件的属性信息之后,所述方法还包括:The method according to any one of claims 1 to 6, wherein after updating the attribute information of the target file in the media database, the method further comprises:
    根据所述媒体数据库中所述目标文件的更新后的属性信息,更新所述终端设备的文件显示应用中所述目标文件的显示状态。According to the updated attribute information of the target file in the media database, the display state of the target file in the file display application of the terminal device is updated.
  8. 根据权利要求7所述的方法,其特征在于,所述根据所述媒体数据库中所述目标文件的更新后的属性信息,更新所述终端设备的文件显示应用中所述目标文件的显示状态,包括:The method according to claim 7, wherein, according to the updated attribute information of the target file in the media database, updating the display state of the target file in the file display application of the terminal device, include:
    若所述媒体数据库中新增了所述目标文件的属性信息,则在所述文件显示应用中新增显示所述目标文件对应的缩略图;或者,If the attribute information of the target file is newly added in the media database, the thumbnail image corresponding to the target file is newly displayed in the file display application; or,
    若所述媒体数据库中删除了所述目标文件的属性信息,则在所述文件显示应用中取消显示所述目标文件对应的缩略图;或者,If the attribute information of the target file is deleted from the media database, cancel the display of the thumbnail image corresponding to the target file in the file display application; or,
    若所述媒体数据库中更新了所述目标文件的属性信息,则在所述文件显示应用中更新显示所述目标文件对应的缩略图。If the attribute information of the target file is updated in the media database, the thumbnail image corresponding to the target file is updated and displayed in the file display application.
  9. 根据权利要求1至8中任一项所述的方法,其特征在于,所述目标文件的属性信息包括以下至少一项:所述目标文件的存储路径信息、所述目标文件的名称信息、所述目标文件的文件大小信息、所述目标文件的文件类型信息、所述目标文件的最后修改时间信息。The method according to any one of claims 1 to 8, wherein the attribute information of the target file includes at least one of the following: storage path information of the target file, name information of the target file, The file size information of the target file, the file type information of the target file, and the last modification time information of the target file.
  10. 一种媒体数据处理装置,其特征在于,所述装置包括处理单元和扫描单元;A media data processing device, characterized in that the device comprises a processing unit and a scanning unit;
    所述处理单元,用于当接收到第一应用发送的针对目标文件的处理请求时,调用所述装置的文件系统的第一接口,按照所述处理请求指示的处理方式对所述目标文件进行处理;The processing unit is configured to, when receiving a processing request for the target file sent by the first application, call the first interface of the file system of the device, and perform the processing on the target file according to the processing mode indicated by the processing request. deal with;
    所述扫描单元,用于若所述目标文件为媒体类型的文件,则执行文件扫描,得到所述目标文件对应的扫描结果;The scanning unit is configured to perform file scanning if the target file is a media type file to obtain a scan result corresponding to the target file;
    所述处理单元,还用于根据所述目标文件对应的扫描结果,在所述装置的媒体数据库中更新所述目标文件的属性信息。The processing unit is further configured to update the attribute information of the target file in the media database of the device according to the scanning result corresponding to the target file.
  11. 根据权利要求10所述的装置,其特征在于,所述处理单元还用于调用所述文件系统的第二接口,判断所述目标文件是否为媒体类型的文件。The apparatus according to claim 10, wherein the processing unit is further configured to call a second interface of the file system to determine whether the target file is a media type file.
  12. 根据权利要求10或11所述的装置,其特征在于,The device according to claim 10 or 11, characterized in that,
    所述处理单元,还用于经由所述文件系统的守护进程向所述扫描单元上报第一消息,所述第一消息用于指示执行文件扫描;The processing unit is further configured to report a first message to the scanning unit via a daemon process of the file system, where the first message is used to instruct to perform file scanning;
    所述扫描单元,具体用于根据所述第一消息,启动媒体文件扫描服务进程,执行媒体文件扫描。The scanning unit is specifically configured to start a media file scanning service process according to the first message, and perform media file scanning.
  13. 根据权利要求10至12中任一项所述的装置,其特征在于,所述处理单元具 体用于:The device according to any one of claims 10 to 12, wherein the processing unit is specifically used for:
    若所述处理请求用于指示新增所述目标文件,则调用所述文件系统的新增接口,在所述装置的存储器中存储所述目标文件;或者,If the processing request is used to instruct to add the target file, call the new interface of the file system to store the target file in the memory of the device; or,
    若所述处理请求用于指示删除所述目标文件,则调用所述文件系统的删除接口,删除所述存储器中存储的所述目标文件;或者,If the processing request is used to instruct to delete the target file, call the delete interface of the file system to delete the target file stored in the memory; or,
    若所述处理请求用于指示修改所述目标文件,则调用所述文件系统的修改接口,修改所述目标文件,并将所述存储器中存储的所述目标文件更新为修改后的所述目标文件。If the processing request is used to instruct to modify the target file, call the modification interface of the file system, modify the target file, and update the target file stored in the memory to the modified target file document.
  14. 根据权利要求10至13中任一项所述的装置,其特征在于,所述处理单元具体用于:The device according to any one of claims 10 to 13, wherein the processing unit is specifically configured to:
    若所述目标文件对应的扫描结果为所述目标文件被新增到所述装置的存储器中、且所述媒体数据库中不存在所述目标文件的属性信息,则获取所述目标文件的属性信息,并在所述媒体数据库中新增所述目标文件的属性信息;或者,If the scan result corresponding to the target file is that the target file is newly added to the memory of the device, and the attribute information of the target file does not exist in the media database, obtain the attribute information of the target file , and add the attribute information of the target file in the media database; or,
    若所述目标文件对应的扫描结果为所述存储器中的所述目标文件被删除、且所述媒体数据库中存在所述目标文件的属性信息,则删除所述媒体数据库中所述目标文件的属性信息;或者,If the scan result corresponding to the target file is that the target file in the storage is deleted and the attribute information of the target file exists in the media database, delete the attribute of the target file in the media database information; or,
    若所述目标文件对应的扫描结果为所述存储器中的所述目标文件被修改、且所述媒体数据库中存在修改前的所述目标文件的属性信息,则获取修改后的所述目标文件的属性信息,并将所述媒体数据库中修改前的所述目标文件的属性信息替换为修改后的所述目标文件的属性信息。If the scan result corresponding to the target file is that the target file in the storage is modified and the media database has attribute information of the target file before modification, obtain the modified target file's attribute information. attribute information, and replace the attribute information of the target file before modification in the media database with the attribute information of the target file after modification.
  15. 根据权利要求14所述的装置,其特征在于,所述处理单元具体用于:The apparatus according to claim 14, wherein the processing unit is specifically configured to:
    通过文件解析服务进程对新增的所述目标文件进行解析,得到所述目标文件的属性信息;或者,The newly added target file is parsed by the file parsing service process to obtain attribute information of the target file; or,
    通过所述文件解析服务进程对修改后的所述目标文件进行解析,得到修改后的所述目标文件的属性信息。The modified target file is parsed by the file analysis service process to obtain attribute information of the modified target file.
  16. 根据权利要求10至15中任一项所述的装置,其特征在于,所述处理单元还用于在所述媒体数据库中更新所述目标文件的属性信息之后,根据所述媒体数据库中所述目标文件的更新后的属性信息,更新所述装置的文件显示应用中所述目标文件的显示状态。The device according to any one of claims 10 to 15, wherein the processing unit is further configured to, after updating the attribute information of the target file in the media database, The updated attribute information of the target file updates the display state of the target file in the file display application of the device.
  17. 根据权利要求16所述的装置,其特征在于,所述处理单元具体用于:The apparatus according to claim 16, wherein the processing unit is specifically configured to:
    若所述媒体数据库中新增了所述目标文件的属性信息,则在所述文件显示应用中新增显示所述目标文件对应的缩略图;或者,If the attribute information of the target file is newly added in the media database, the thumbnail image corresponding to the target file is newly displayed in the file display application; or,
    若所述媒体数据库中删除了所述目标文件的属性信息,则在所述文件显示应用中取消显示所述目标文件对应的缩略图;或者,If the attribute information of the target file is deleted from the media database, cancel the display of the thumbnail image corresponding to the target file in the file display application; or,
    若所述媒体数据库中更新了所述目标文件的属性信息,则在所述文件显示应用中更新显示所述目标文件对应的缩略图。If the attribute information of the target file is updated in the media database, the thumbnail image corresponding to the target file is updated and displayed in the file display application.
  18. 根据权利要求10至17中任一项所述的装置,其特征在于,所述目标文件的属性信息包括以下至少一项:所述目标文件的存储路径信息、所述目标文件的名称信息、所述目标文件的文件大小信息、所述目标文件的文件类型信息、所述目标文件的 最后修改时间信息。The device according to any one of claims 10 to 17, wherein the attribute information of the target file includes at least one of the following: storage path information of the target file, name information of the target file, all The file size information of the target file, the file type information of the target file, and the last modification time information of the target file.
  19. 一种终端设备,其特征在于,包括处理器,所述处理器与存储器耦合,所述处理器用于执行所述存储器中存储的计算机程序或指令,以使得所述终端设备实现如权利要求1至9中任一项所述的方法。A terminal device, characterized in that it includes a processor, wherein the processor is coupled to a memory, and the processor is configured to execute a computer program or instruction stored in the memory, so that the terminal device implements the methods according to claims 1 to 1. The method of any one of 9.
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,当所述计算机程序在终端设备上运行时,使得所述终端设备执行如权利要求1至9中任一项所述的方法。A computer-readable storage medium, characterized in that, the computer-readable storage medium stores a computer program, when the computer program runs on a terminal device, the terminal device is made to execute any one of claims 1 to 9. one of the methods described.
  21. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序,当所述计算机程序被计算机执行时,使得所述计算机实现如权利要求1至9中任一项所述的方法。A computer program product, characterized in that the computer program product comprises a computer program, which, when executed by a computer, causes the computer to implement the method according to any one of claims 1 to 9.
PCT/CN2021/141323 2021-01-25 2021-12-24 Media data processing method and apparatus, and terminal device WO2022156484A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110098318.8 2021-01-25
CN202110098318.8A CN114791961A (en) 2021-01-25 2021-01-25 Media data processing method and device and terminal equipment

Publications (1)

Publication Number Publication Date
WO2022156484A1 true WO2022156484A1 (en) 2022-07-28

Family

ID=82460287

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/141323 WO2022156484A1 (en) 2021-01-25 2021-12-24 Media data processing method and apparatus, and terminal device

Country Status (2)

Country Link
CN (1) CN114791961A (en)
WO (1) WO2022156484A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115495398A (en) * 2022-09-28 2022-12-20 北京亚控科技发展有限公司 Interface resource operation method and device, electronic equipment, storage medium and product
WO2024041188A1 (en) * 2022-08-26 2024-02-29 华为技术有限公司 Data management method and corresponding device

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116700768B (en) * 2022-10-20 2024-04-02 荣耀终端有限公司 Application processing method and related device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105426386A (en) * 2015-10-23 2016-03-23 小米科技有限责任公司 File synchronization method and apparatus, and terminal device
CN106559563A (en) * 2016-10-31 2017-04-05 努比亚技术有限公司 Image processing method and device
US20170220588A1 (en) * 2014-11-04 2017-08-03 Shenzhen Skyworth Digital Technology Co.,Ltd Method and system for scanning local media file
CN107451475A (en) * 2017-06-15 2017-12-08 努比亚技术有限公司 Multimedia file scan method and equipment, computer-readable recording medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170220588A1 (en) * 2014-11-04 2017-08-03 Shenzhen Skyworth Digital Technology Co.,Ltd Method and system for scanning local media file
CN105426386A (en) * 2015-10-23 2016-03-23 小米科技有限责任公司 File synchronization method and apparatus, and terminal device
CN106559563A (en) * 2016-10-31 2017-04-05 努比亚技术有限公司 Image processing method and device
CN107451475A (en) * 2017-06-15 2017-12-08 努比亚技术有限公司 Multimedia file scan method and equipment, computer-readable recording medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024041188A1 (en) * 2022-08-26 2024-02-29 华为技术有限公司 Data management method and corresponding device
CN115495398A (en) * 2022-09-28 2022-12-20 北京亚控科技发展有限公司 Interface resource operation method and device, electronic equipment, storage medium and product
CN115495398B (en) * 2022-09-28 2023-06-30 北京亚控科技发展有限公司 Interface resource operation method, device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN114791961A (en) 2022-07-26

Similar Documents

Publication Publication Date Title
WO2022156484A1 (en) Media data processing method and apparatus, and terminal device
KR102124231B1 (en) Streaming content and placeholders
US8868666B1 (en) Methods, devices and systems for content discovery, aggregation and presentment over a network
KR102128139B1 (en) File management with placeholders
US7945535B2 (en) Automatic publishing of digital content
US9298747B2 (en) Deployable, consistent, and extensible computing environment platform
US20120109952A1 (en) System, method, and computer program for remote management of digital content
US20170169050A1 (en) Method and electronic device for file system synchronization
US20170262538A1 (en) Method of and system for grouping object in a storage device
CN114116611A (en) File scanning method and related device
CN103246729A (en) Method and system for processing multi-media files of android mobile terminal
CN113535652B (en) Method and device for accessing multimedia file in android operating environment
KR20160086754A (en) Firmware refreshing method and device
WO2024078348A1 (en) Method and apparatus for processing registry operation in application porting environment, and medium
EP2686791B1 (en) Variants of files in a file system
CN110798521B (en) File sharing method and device, electronic equipment and storage medium
CN112825072A (en) Communication terminal and data sharing method
CN113591000B (en) Browser engine switching method, device and equipment
US8588851B2 (en) Android mobile telephone comprising a content supply chain
US8990265B1 (en) Context-aware durability of file variants
CN111274210B (en) Metadata processing method and device and electronic equipment
WO2024022176A1 (en) System operation method and terminal apparatus
WO2024051654A1 (en) File processing method and electronic device
WO2022252791A1 (en) Data transmission method, electronic device, and computer readable storage medium
US20210141771A1 (en) Method of managing files by mobile device and mobile device for implementing the same

Legal Events

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

Ref document number: 21920858

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21920858

Country of ref document: EP

Kind code of ref document: A1