Media transmission protocol instruction execution method and device, terminal equipment and storage medium
By segmenting files and generating priority scheduling instruction queues, the response latency problem in media transmission protocols is solved, achieving logical quasi-concurrency processing and improving the efficiency of data exchange between devices and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-15
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, media transmission protocols suffer from response latency issues during data exchange between devices, and the asynchronous sensing function of proprietary drivers or custom software lacks universality and cross-platform compatibility.
The file to be downloaded is divided into multiple logical data blocks of fixed size, corresponding media transmission instructions are generated and stored in the instruction queue. The instruction queue has a priority scheduling function, which sets the priority according to the operation type and executes the instructions to achieve logical quasi-concurrent processing.
It improved the system's real-time responsiveness and smoothness of interaction, enhanced the flexibility of human-computer interaction, alleviated user anxiety while waiting, and improved user satisfaction.
Smart Images

Figure CN121864783A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information control technology, and in particular to a media transmission protocol instruction execution method, apparatus, terminal device and storage medium. Background Technology
[0002] In the process of data interaction between consumer electronics products such as mobile devices, digital cameras, and media players and computers, the Media Transfer Protocol (MTP) is a widely used communication protocol used to securely transfer media files and manage data on the device between the host (such as a PC) and the device. Proposed and standardized by Microsoft, the MTP was designed to replace the traditional USB mass storage mode, enabling cross-platform data exchange while protecting the integrity of the device's file system. While some existing technologies attempt to alleviate response latency issues through polling, timeout retries, or client-side caching, they do not fundamentally overcome the limitation of the MTP's single-channel serial execution. Some manufacturers (such as Sony, Samsung, and Huawei) have implemented limited asynchronous sensing functionality in their proprietary drivers or custom software, but these solutions largely rely on device-side firmware support and lack universality and cross-platform compatibility. Summary of the Invention
[0003] In view of this, embodiments of this application provide a media transmission protocol instruction execution method, apparatus, terminal device, and storage medium, which can effectively solve the response delay problem, etc.
[0004] In a first aspect, embodiments of this application provide a media transmission protocol instruction execution method, including: The file to be downloaded is divided into multiple logical data blocks of fixed size; For each logical data block, a corresponding media transmission instruction for segmented download is generated, and all the segmented download instructions are stored in an instruction queue; the instruction queue has a priority scheduling function. When other types of media transmission operation instructions are received, a corresponding priority is set according to the operation type of the media transmission operation instruction, and the media transmission operation instruction is added to the instruction queue with the corresponding priority. Instructions are retrieved and sent to the media transmission device in order of priority from the instruction queue to execute the corresponding media transmission instruction.
[0005] In some embodiments, dividing the file to be downloaded into multiple logical data blocks of fixed size includes: The file is divided into several logical data blocks in sequence using a fixed length as the block unit. If the last logical data block is less than the fixed length, the remaining part is retained. Each logical data block corresponds to a continuous data offset address and block number, used to identify the download location and the recovery breakpoint.
[0006] In some embodiments, the instruction queue includes at least two priority levels: The first priority level is used to store segmented download instructions; The second priority and above are used to store media transmission operation instructions that require immediate response, and their execution priority is higher than that of the first priority. When there are instructions to be executed in the high-priority queue, pause the current low-priority segmented download task and execute the high-priority instructions first.
[0007] In some embodiments, if a communication interruption occurs during segmented download, the number and offset of the successfully downloaded data block are recorded. After the connection is restored, a segmented download request for the data block is re-initiated based on the recorded data block number and offset to resume the interrupted download.
[0008] In some embodiments, the other types of media transmission operation instructions include one or more of the following: file upload, file deletion, attribute reading, directory browsing, device information query, and setting operations.
[0009] In some embodiments, all media transmission instructions are subject to validity verification and parameter checks before submission. If a media transmission instruction fails the validity verification and parameter checks, it is not executed.
[0010] In some embodiments, the method further includes: The priority of segmented download commands is dynamically adjusted based on system load, user interaction status, or network conditions.
[0011] Secondly, this application also provides a media transmission protocol instruction execution device, comprising: The segmentation module is used to divide the file to be downloaded into multiple logical data blocks of fixed size; The instruction generation module is used to generate a corresponding media transmission instruction for segmented download for each logical data block, and store all the segmented download instructions into an instruction queue; the instruction queue has a priority scheduling function. The instruction storage module is used to set a corresponding priority according to the operation type of other types of media transmission operation instructions when other types of media transmission operation instructions are received, and to add the media transmission operation instructions to the instruction queue with the corresponding priority. The instruction execution module is used to retrieve and send instructions to the media transmission device in order of priority in the instruction queue, so as to execute the corresponding media transmission instructions.
[0012] Thirdly, this application also provides a terminal device, the terminal device including a processor and a memory, the memory storing a computer program, and the processor executing the computer program to implement the media transmission protocol instruction execution method.
[0013] Fourthly, this application also provides a readable storage medium storing a computer program, which, when executed on a processor, implements the media transmission protocol instruction execution method described above.
[0014] The embodiments of this application have the following beneficial effects: The method in this embodiment divides the file to be downloaded into multiple logical data blocks of fixed size. For each logical data block, a corresponding media transmission instruction for segmented download is generated, and all segmented download instructions are stored in an instruction queue. The instruction queue has a priority scheduling function. When other types of media transmission operation instructions are received, a corresponding priority is set according to the operation type of the media transmission operation instruction, and the media transmission operation instruction is added to the instruction queue with the corresponding priority. Instructions are retrieved and sent to the media transmission device in order of priority in the instruction queue to execute the corresponding media transmission instruction. This achieves quasi-concurrent processing capability in logic, significantly improves the real-time response capability and interaction smoothness of the system, significantly enhances the flexibility and naturalness of human-computer interaction, effectively alleviates user waiting anxiety, and improves overall operation satisfaction. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This paper illustrates a schematic diagram of a media transmission protocol instruction execution flow according to an embodiment of this application. Figure 2 This paper illustrates a schematic diagram of a media transmission protocol instruction execution flow according to an embodiment of this application. Figure 3 A schematic diagram of a media transmission protocol instruction execution device according to an embodiment of this application is shown. Detailed Implementation
[0017] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0018] The components of the embodiments of this application described and illustrated in the accompanying drawings can be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of this application provided in the drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0019] In the following text, the terms "comprising," "having," and their cognates, which may be used in various embodiments of this application, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as primarily excluding the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more combinations thereof. Furthermore, the terms "first," "second," "third," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance.
[0020] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of this application pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be construed as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of this application.
[0021] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0022] To address the problems of existing technologies, this application provides a media transmission protocol instruction execution method. This method divides the file to be downloaded into multiple fixed-size logical data blocks. For each logical data block, a corresponding media transmission instruction for segmented download is generated, and all segmented download instructions are stored in an instruction queue. The instruction queue has a priority scheduling function. When other types of media transmission operation instructions are received, a corresponding priority is set according to the operation type of the media transmission operation instruction, and the media transmission operation instruction is added to the instruction queue with the corresponding priority. Instructions are retrieved and sent to the media transmission device sequentially according to the priority order in the instruction queue to execute the corresponding media transmission instruction. This effectively improves the system response speed, resource utilization, and user experience during MTP communication, and is particularly suitable for application scenarios requiring frequent interactive control commands and large data transmission.
[0023] The following describes the method for executing instructions of the media transmission protocol using specific examples.
[0024] Figure 1 A flowchart illustrating a media transmission protocol instruction execution method according to an embodiment of this application is shown. Exemplarily, the media transmission protocol instruction execution method includes the following steps: Step S100: Divide the file to be downloaded into multiple logical data blocks of fixed size.
[0025] This embodiment describes an application scenario for downloading files using the MTP protocol. The MTP protocol is specifically designed for transferring multimedia files between computers and mobile devices, and it accesses files in an object-based manner. Its inherent single-channel, serialized instruction execution mechanism leads to a series of performance bottlenecks, such as the inability to execute other input instructions for a long time during the download of large files.
[0026] Therefore, the method in this embodiment divides a large file into multiple logical data blocks of fixed size when downloading a large file. Here, a large file refers to a file larger than a preset size, such as 1GB.
[0027] When segmenting, a fixed length is used as the block unit, and the file is sequentially divided into several data blocks. If the last data block is less than the fixed length, the remaining part is retained. Each logical data block corresponds to a continuous data offset address and block number, which are used to identify the download position and the recovery breakpoint.
[0028] In this way, a large file is divided into multiple small data blocks, each of which can be downloaded separately. Since each small block corresponds to a consecutive data offset address and block number, the position and sequence of each data block are recorded. Therefore, even if these data blocks are stored out of order later, they can be reassembled using these data offset addresses and block numbers. Thus, this block-based method ensures that after downloading a large file divided into blocks, correct data reassembly can be achieved.
[0029] For example, a large 1GB file can be divided into multiple small data blocks of fixed size 16kb.
[0030] Step S200: For each logical data block, generate a corresponding media transmission instruction for segmented download, and store all the segmented download instructions in an instruction queue; the instruction queue has a priority scheduling function.
[0031] Each logical data block is essentially a small file. Because each logical data block corresponds to a consecutive data offset address and block number, each logical data block can be downloaded individually. Once all logical data blocks have been downloaded, it is equivalent to downloading the large file.
[0032] The MTP protocol can download data using corresponding download commands. Therefore, a corresponding media transfer command for segmented download can be generated for each logical data block. For example, if a large file is divided into 100 data blocks, then 100 corresponding download commands can be generated for each of the 100 data blocks.
[0033] It's understandable that once these 100 download commands are executed, the download of the large file will be complete.
[0034] These instructions are stored in an instruction queue with priority scheduling capabilities. That is, different instructions in this queue have different priorities, and instruction scheduling is performed according to these priority differences. For example, if there are two priority levels, level one being the highest and level two the lowest, then when both level one and level two instructions exist in the queue, the level one instruction will be executed before the level two instruction.
[0035] At the same time, this queue also handles the execution of other commands. It not only executes the download commands mentioned above, but also other MTP commands such as uploading, deleting, reading, setting, directory operations, etc.
[0036] Step S300: When other types of media transmission operation instructions are received, a corresponding priority is set according to the operation type of the media transmission operation instruction, and the media transmission operation instruction is added to the instruction queue with the corresponding priority.
[0037] In real-world applications, there may be situations where a user needs to perform other operations while downloading a file. In such cases, other MTP commands will be generated based on the user's actions, such as the upload, delete, read, and settings commands mentioned above, and then added to the command queue in the previous steps.
[0038] Because this embodiment aims to enable the execution of other commands during the download process, corresponding priorities are set for download commands and other types of media transmission operation commands. In this embodiment, by setting the priority of other commands higher than that of download commands, it is ensured that when other commands appear during the download process, the command with higher priority will be scheduled to the front of the queue for priority execution.
[0039] like Figure 2The diagram shows the instruction execution of this queue. There are two types of instructions in this queue: high-priority instructions and low-priority instructions. These instructions are executed on the MTP device in descending order of priority.
[0040] It is understandable that downloading a large file is a continuous process. When a download operation is performed, as described in the previous steps, a large number of download instructions are pre-stored in the queue. Other instructions generated in between are insertive instructions. If the priority of these insertive instructions is lower than or equal to that of the download instructions, they cannot take effect immediately and must wait for the download to be completed before they can be used. Therefore, in this embodiment, the priority of these other types of media transmission operation instructions is set higher than that of the download instructions to ensure that they can be invoked immediately.
[0041] Step S400: Retrieve and send instructions to the media transmission device in order of priority in the instruction queue to execute the corresponding media transmission instructions.
[0042] like Figure 2 The diagram shown is a schematic of the instruction queue executing a task in this embodiment. The entire queue contains high-priority instructions and low-priority instructions. High-priority instructions are executed first, and then subsequent low-priority instructions are executed in sequence.
[0043] As an example, the instruction queue includes at least two priority levels: the first priority is used to store segmented download instructions; the second priority and above are used to store media transmission operation instructions that require immediate response, with execution priority higher than the first priority; when there are instructions to be executed in the high priority queue, the current low priority segmented download task is paused, and the high priority instructions are executed first.
[0044] Before sending a new instruction, the system first checks if there are any higher-priority instructions in the queue. If so, they are retrieved and executed first; otherwise, the system continues with the next segment download task. This ensures that high-priority instructions always receive a response in the shortest possible time.
[0045] In this way, the download tasks of large files in segments are no longer executed continuously, but are distributed and interspersed among other instructions. Since the transmission time of each segment is very short (milliseconds), multiple different types of operations can be quickly alternated, presenting an effect of "almost simultaneous execution" at the user's perception level.
[0046] If a segment download fails due to connection interruption, simply record the sequence number of the largest consecutive block that has been completed. Once the connection is restored, the request for that segment can be re-initiated from the point of interruption, without having to download the entire file again, which greatly improves transmission robustness.
[0047] Furthermore, the priority of segmented download commands can be dynamically adjusted based on system load, user interaction status, or network conditions to balance background download efficiency with foreground operation response speed. For example, when it is detected that a user is browsing a photo album, the priority of image thumbnail retrieval requests is automatically increased.
[0048] For failed segmented downloads or control commands, set reasonable retry counts and backoff intervals to prevent infinite loops or avalanche effects. Therefore, manual intervention and log backtracking can be configured to improve fault tolerance.
[0049] Furthermore, because this embodiment divides large files into fixed-size logical data blocks for download, when the network connection is lost, only the download of the current data block will be interrupted. Once the network is restored, the download can resume from the interrupted data block, thus realizing the function of resuming interrupted file downloads.
[0050] The Media Transfer Protocol (MTP) instruction execution method in this embodiment divides the file to be downloaded into blocks, breaking down a download task that requires downloading a large amount of data at once into multiple smaller data blocks. This allows other instructions to be inserted during the download process, and by adjusting the priority of these instructions, later-inserted instructions can be queued for execution. High-priority MTP instructions (such as device status queries, file deletion, directory browsing, etc.) can preemptively execute among low-priority segmented download instructions. This design overcomes the limitations of native serial communication in the MTP protocol, achieving quasi-concurrent processing capabilities in the absence of physical multi-channel support, significantly improving the system's real-time responsiveness and interactive smoothness. This invention allows users to perform common operations such as viewing photo albums, deleting unnecessary files, and creating new directories while downloading large files, significantly enhancing the flexibility and naturalness of human-computer interaction, effectively alleviating user anxiety during waiting, and improving overall user satisfaction.
[0051] Figure 3 A schematic diagram of a media transmission protocol instruction execution apparatus according to an embodiment of this application is shown. Exemplarily, the media transmission protocol instruction execution apparatus includes: Segmentation module 10 is used to divide the file to be downloaded into multiple logical data blocks of fixed size; The instruction generation module 20 is used to generate a corresponding media transmission instruction for segmented download for each logical data block, and store all the segmented download instructions into an instruction queue; the instruction queue has a priority scheduling function. The instruction storage module 30 is used to set a corresponding priority according to the operation type of other types of media transmission operation instructions when other types of media transmission operation instructions are received, and to add the media transmission operation instructions to the instruction queue with the corresponding priority. The instruction execution module 40 is used to retrieve and send instructions to the media transmission device in order of priority in the instruction queue to execute the corresponding media transmission instructions.
[0052] It is understood that the apparatus of this embodiment corresponds to the media transmission protocol instruction execution method of the above embodiments, and the options in the above embodiments are also applicable to this embodiment, so they will not be described again here.
[0053] This application also provides a terminal device, exemplary of which includes a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to enable the terminal device to perform the functions of the various modules in the above-described media transmission protocol instruction execution method or the above-described media transmission protocol instruction execution apparatus.
[0054] The processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including at least one of a Central Processing Unit (CPU), Graphics Processing Unit (GPU), Network Processor (NP), Digital Signal Processor (DSP), Application-Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor or any conventional processor, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application.
[0055] The memory can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc. The memory is used to store computer programs, and the processor can execute the computer programs accordingly after receiving execution instructions.
[0056] This application also provides a readable storage medium for storing the computer program used in the aforementioned terminal device.
[0057] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, in alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0058] In addition, the functional modules or units in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0059] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0060] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for executing media transmission protocol instructions, characterized in that, include: The file to be downloaded is divided into multiple logical data blocks of fixed size; For each logical data block, a corresponding media transmission instruction for segmented download is generated, and all the segmented download instructions are stored in the instruction queue; The instruction queue has a priority scheduling function; When other types of media transmission operation instructions are received, a corresponding priority is set according to the operation type of the media transmission operation instruction, and the media transmission operation instruction is added to the instruction queue with the corresponding priority. Instructions are retrieved and sent to the media transmission device in order of priority from the instruction queue to execute the corresponding media transmission instruction.
2. The media transmission protocol instruction execution method according to claim 1, characterized in that, The process of dividing the file to be downloaded into multiple logical data blocks of fixed size includes: The file is sequentially divided into several logical data blocks using a fixed length as the block unit, wherein if the last block is less than the fixed length, the remaining part is retained. Each logical data block is configured with a continuous data offset address and a block number, which are used to identify the download position and the recovery breakpoint.
3. The media transmission protocol instruction execution method according to claim 1, characterized in that, The instruction queue includes at least two priority levels: The first priority level is used to store segmented download instructions; The second priority and above are used to store media transmission operation instructions that require immediate response, and their execution priority is higher than that of the first priority. When there are instructions to be executed in the high-priority queue, pause the current low-priority segmented download task and switch to execute the high-priority instructions to be executed.
4. The media transmission protocol instruction execution method according to claim 1, characterized in that, Also includes: If a communication interruption occurs during the segmented download process, the number and offset of the successfully downloaded data block are recorded. After the connection is restored, the segmented download request for the data block is re-initiated according to the recorded data block number and offset to resume the interrupted download.
5. The media transmission protocol instruction execution method according to claim 2, characterized in that, The other types of media transmission operation instructions include one or more of the following: file upload, file deletion, attribute reading, directory browsing, device information query, and setting operations.
6. The media transmission protocol instruction execution method according to claim 1, characterized in that, All media transmission commands undergo validity verification and parameter checks before submission. If a media transmission command fails the validity verification and parameter checks, it will not be executed.
7. The media transmission protocol instruction execution method according to claim 1, characterized in that, Also includes: The priority of segmented download commands is dynamically adjusted based on system load, user interaction status, or network conditions.
8. A media transmission protocol instruction execution device, characterized in that, include: The segmentation module is used to divide the file to be downloaded into multiple logical data blocks of fixed size; The instruction generation module is used to generate a corresponding media transmission instruction for segmented download for each logical data block, and store all the segmented download instructions into the instruction queue; The instruction queue has a priority scheduling function; The instruction storage module is used to set a corresponding priority according to the operation type of other types of media transmission operation instructions when other types of media transmission operation instructions are received, and to add the media transmission operation instructions to the instruction queue with the corresponding priority. The instruction execution module is used to retrieve and send instructions to the media transmission device in order of priority in the instruction queue, so as to execute the corresponding media transmission instructions.
9. A terminal device, characterized in that, The terminal device includes a processor and a memory, the memory storing a computer program, and the processor executing the computer program to implement the media transmission protocol instruction execution method according to any one of claims 1-7.
10. A readable storage medium, characterized in that, It stores a computer program, which, when executed on a processor, implements the media transmission protocol instruction execution method according to any one of claims 1-7.