P2P channel establishment method and device and electronic equipment

By jumping in the P2P channel waiting queue of the terminal to establish a P2P channel between the target device and the terminal, the problem of limited number of P2P pipelines that the terminal can establish at the same time is solved, and the connection needs of the target device are quickly responded to and the efficiency of the P2P channel is improved.

CN119814799APending Publication Date: 2025-04-11TP-LINK INT CHENGDU CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411929469.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

Under the limitations of terminal performance and system settings, the number of P2P pipelines that the terminal can establish at the same time is limited, which makes it impossible to establish P2P channels for remote devices in a timely manner, affecting the timeliness of information transmission.

Method used

By jumping into the queue, the target device is determined and added to the head of the waiting queue, and a P2P channel between the target device and the terminal is established to ensure that the connection needs of the target device are promptly responded to the target device when the terminal resources allow.

Benefits of technology

It realizes that when the number of terminal P2P pipelines is limited, it quickly responds to the connection needs of the target equipment, improves the efficiency of the P2P channel, and solves the problem of low experience when the terminal establishes the required P2P channels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814799A_ABST
    Figure CN119814799A_ABST
Patent Text Reader

Abstract

The invention discloses a P2P (Peer-to-Peer) channel establishment method, a P2P channel establishment device and electronic equipment. The method comprises the following steps: determining target equipment which is about to establish a P2P channel with a terminal; and under the condition that a plurality of devices waiting to establish the P2P channel with the terminal exist, queue jumping is carried out to establish the P2P channel between the target device and the terminal. According to the method and the device, the technical problem of low experience when the terminal establishes the required P2P channel is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular to a method, device and electronic device for establishing a P2P channel. Background Art

[0002] When establishing a P2P channel between a terminal and a remote device (such as a camera), the terminal's performance and system settings will limit the number of P2P channels that the terminal can establish at the same time. When the number of P2P channels established by the terminal reaches the upper limit, a P2P channel cannot be established immediately for the remote device that wants to establish a P2P channel with the terminal, and the terminal cannot receive information transmitted by the remote device in a timely manner.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present invention provide a method, device and electronic device for establishing a P2P channel, so as to at least solve the technical problem that a terminal has a low experience when establishing a required P2P channel.

[0005] According to one aspect of an embodiment of the present invention, a P2P channel establishment method is provided, comprising: determining a target device to establish a P2P channel with a terminal; and when there are multiple devices waiting to establish a P2P channel with the terminal, establishing a P2P channel between the target device and the terminal.

[0006] Optionally, at least one of the following methods is used to determine the target device for establishing a P2P channel with the terminal: receiving a sliding operation on a device list, and determining that one or more devices displayed when the sliding operation stops are the target devices; receiving a selection operation on one or more devices, and determining that the one or more devices selected by the selection operation are the target devices.

[0007] Optionally, when there are multiple devices waiting to establish a P2P channel with the terminal, establishing the P2P channel between the target device and the terminal by jumping in line includes: obtaining a waiting queue of the multiple devices waiting to establish a P2P channel with the terminal; adding the target device to the head of the waiting queue, and establishing a P2P channel between the target device at the head of the queue and the terminal.

[0008] Optionally, adding the target device to the head of the waiting queue and establishing a P2P channel between the target device at the head of the queue and the terminal includes: determining whether the number of P2P channels of the terminal exceeds a first channel number threshold, wherein the P2P channels of the terminal include: P2P channels waiting to be established, P2P channels being established, and P2P channels that have been established; if the number of P2P channels of the terminal does not exceed the first channel number threshold, directly adding the target device to the head of the waiting queue and establishing a P2P channel between the target device at the head of the queue and the terminal; and / or, if the number of P2P channels of the terminal exceeds the first channel number threshold, after terminating one or more P2P channels from the P2P channels of the terminal, adding the target device to the head of the waiting queue and establishing a P2P channel between the target device at the head of the queue and the terminal.

[0009] Optionally, terminating one or more P2P channels from the P2P channels of the terminal includes: determining the priority of the P2P channels of the terminal based on the following factors: whether it is a P2P channel waiting to be established, whether it is a P2P channel being established, whether it is a P2P channel that has been established, and the usage time of the P2P channel after it has been established; and selecting one or more P2P channels with low priority from the P2P channels of the terminal to terminate.

[0010] Optionally, the establishing the P2P channel between the target device at the head of the team and the terminal includes: determining whether the number of the P2P channels being established exceeds a second channel number threshold; directly establishing the P2P channel between the target device at the head of the team and the terminal when the number of the P2P channels being established does not exceed the second channel number threshold; and / or, establishing the P2P channel between the target device at the head of the team and the terminal after terminating one or more P2P channels from the P2P channels being established when the number of the P2P channels being established exceeds the second channel number threshold.

[0011] Optionally, after the interruption in establishing the P2P channel between the target device and the terminal, the method further includes: monitoring a channel state of the P2P channel between the target device and the terminal; and terminating the P2P channel between the target device and the terminal when the channel state is invalid.

[0012] According to another aspect of the present invention, a P2P channel establishment device is provided, comprising: a determination module, used to determine a target device to establish a P2P channel with a terminal; and an establishment module, used to, when there are multiple devices waiting to establish a P2P channel with the terminal, interrupt the queue to establish the P2P channel between the target device and the terminal.

[0013] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned P2P channel establishment methods.

[0014] According to another aspect of the present invention, an electronic device is provided, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes any one of the above-mentioned P2P channel establishment methods when running.

[0015] According to yet another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the steps of any one of the methods for establishing a P2P channel are implemented.

[0016] In the embodiment of the present invention, a queue-jumping method is adopted to establish a P2P channel between the target device and the terminal, thereby achieving the purpose of immediately establishing the P2P channel between the target device and the terminal, thereby achieving the technical effect of quickly responding to the connection needs of the target device when the number of P2P pipes that can be established by the terminal at the same time is limited, and further solving the technical problem of low experience when the terminal establishes the required P2P channel. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0018] Figure 1 is a flow chart of a P2P channel establishment method according to an embodiment of the present invention;

[0019] Figure 2 is a schematic diagram of a P2P fast queue-jumping method according to an optional implementation mode of the present invention;

[0020] Figure 3 It is a structural block diagram of a P2P channel establishment device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0021] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0023] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:

[0024] P2P (Peer-to-Peer) channel: usually refers to a direct communication connection established between two peer nodes (Peer). This connection allows data to be transmitted directly from one device to another without being transferred through a central server. Due to performance and other factors, there is an upper limit on the number of P2P channels for a device. P2P channels can be divided into three types according to their establishment status, namely, P2P channels waiting to be established, P2P channels being established, and P2P channels that have been established. Among them, in the waiting to be established state, a direct communication connection has not yet been established between the two peer nodes. The P2P channel is in a waiting state and is ready to receive a request to establish a connection. In the establishing state, the communication channel is being established between the peer nodes, which usually involves steps such as address resolution and network traversal to ensure that data can be directly transmitted between the two peer nodes. It is also called ongoing P2P penetration. Due to performance and other factors, there is an upper limit to the number of P2P penetrations allowed to be performed simultaneously on a device, that is, there is an upper limit to the number of P2P channels allowed to be in the establishing state at the same time. In the established state, the P2P channel is established and the two peer nodes can exchange data directly and in real time. For example, a P2P channel can be established between a mobile phone APP and a camera for the transmission of real-time video streams, which can provide lower latency and higher efficiency.

[0025] In the security field, when users watch the real-time camera images through the APP client of mobile devices such as mobile phones, they use P2P channels to transmit video streams. This is because the P2P channel transmission method has the advantages of low cost and low latency. However, when establishing and using P2P channels, there are the following problems:

[0026] Due to the limitations of the performance of mobile devices, system settings, etc., the upper limit of the number of P2P channels of mobile devices (including P2P channels waiting to be established, being established, and established) is relatively low. When the number of P2P channels of a mobile device reaches the upper limit, for a device that still needs to establish a P2P channel with the mobile device and wants to play the video of the device, a new P2P channel cannot be established immediately for the device. Secondly, if multiple P2P channels are penetrated at the same time, the central processing unit (CPU) of the mobile device will be used at a high rate, and the user experience will be poor, especially in multi-screen mode (i.e., the mobile device plays videos of multiple devices simultaneously through multiple windows), and some mobile devices have obvious operation jams. In addition, there is no sufficiently real-time and accurate detection mechanism to determine whether the P2P channel has been disconnected or become unavailable, that is, the real-time detection of the P2P channel availability is insufficient. If a P2P channel has been disconnected and this situation is not detected immediately, the mobile device will still try to use the P2P channel to pull the video stream, and can only end the attempt after a timeout, resulting in increased user waiting time and delayed video playback, thereby reducing the user's experience of watching videos.

[0027] In this regard, there is a lack of a relatively effective solution, which enables timely establishment of P2P channels for devices that users want to watch when the total number of P2P channels is limited, and does not cause obvious lags in the user's use. Although the relevant technologies involve the establishment of some P2P channels, they cannot achieve the technical effect of timely establishment of P2P channels for devices that users want to watch when the total number of P2P channels is limited, and does not cause obvious lags in the user's use. In order to solve this technical problem, an embodiment of the present invention provides a P2P channel establishment method.

[0028] According to an embodiment of the present invention, an embodiment of a method for establishing a P2P channel is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0029] Figure 1 is a flow chart of a P2P channel establishment method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:

[0030] Step S102, determining a target device with which a P2P channel is to be established.

[0031] As an optional embodiment, the execution subject of the method of this embodiment may be a mobile device or terminal used to establish a P2P channel with other devices, including but not limited to a smart phone, a tablet computer, a laptop computer, etc. These mobile devices can establish a P2P channel with other devices at any time without being restricted by time and location, and provide real-time video streaming transmission services.

[0032] As an optional embodiment, when determining the target device to establish a P2P channel with the terminal, multiple methods can be used. For example, the user can determine the target device to establish a P2P channel with the terminal by directly clicking or other methods. This method can most directly and clearly obtain the user's selection requirements for the target device. For another example, the user behavior can also be used to predictively determine the target device to establish a P2P channel with the terminal. For example, according to the user's selection frequency, the frequently selected device can be determined as the target device, and the P2P channel can be established in advance to improve the user experience. For another example, the target device can be determined in combination with multiple methods, such as receiving a sliding operation of sliding the device list, determining that one or more devices displayed when the above sliding operation stops are the above target devices; receiving a selection operation for one or more devices, and determining that the above one or more devices selected by the above selection operation are the above target devices. For example, in the device management list of the mobile phone APP, the user slides up and down to view the multiple cameras monitored by himself. When the user no longer slides the list, a P2P channel can be established between the one or more cameras in the mobile phone display interface and the mobile phone; when the user clicks on one or more cameras in the selection list, a P2P channel can also be established between the selected one or more cameras and the mobile phone. By combining the device list sliding stop and selection operations, it is possible to respond to user needs immediately and make predictive preparations, thereby improving the flexibility of P2P channel establishment and resource utilization efficiency, making operations more direct and smooth.

[0033] S104: When there are multiple devices waiting to establish a P2P channel with the terminal, establish a P2P channel between the target device and the terminal.

[0034] As an optional embodiment, the number of P2P channels that the terminal allows to be established at the same time is limited, and more devices that need to establish a P2P channel with the terminal are in a state of waiting to be established. After the target device is determined, the target device will also enter the waiting queue. Among them, there are many ways for the target device to enter the waiting queue, for example, in the order of first come first served, it is arranged at the end of the waiting queue. This sequential queuing method ignores the priority of the user, so that the queuing waiting time of the target device is long, resulting in response delay. For another example, the queue-jumping method can be used to give priority to the P2P channel establishment request between the target device and the terminal, respond to user needs in a timely manner, reduce pipeline timeouts and failures caused by long waiting time, and improve the use efficiency of the P2P channel. For example, the target device can be directly inserted into the first place of the device waiting to establish a P2P channel, and the waiting queue of the multiple devices waiting to establish a P2P channel with the terminal can be obtained first; then the target device is added to the head of the waiting queue, and the P2P channel between the target device at the head of the queue and the terminal is established. The method of directly inserting to the first place is simple and direct, without considering the waiting status of other devices, and can achieve the effect of immediately establishing a P2P channel between the target device and the terminal. The method of obtaining the waiting queue and then joining the first of the waiting queue can consider the waiting status of other devices while giving priority to the request of the target device, reduce the impact on other devices, and avoid frequently interrupting the establishment process of the P2P channel of other devices, which not only meets the immediate needs, but also takes into account the long-term use efficiency.

[0035] As an optional embodiment, when adding the target device to the head of the waiting queue and establishing a P2P channel between the target device at the head of the queue and the terminal, multiple methods may be used.

[0036] For example, a portion of terminal resources may be reserved in advance for establishing a P2P channel with a target device. When the target device joins the head of the waiting queue, the reserved terminal resources are enabled to directly establish a P2P channel between the target device at the head of the queue and the terminal.

[0037] For another example, the terminal resources can be used normally, and after determining the target device, it is determined whether the number of P2P channels of the terminal exceeds the first channel number threshold, wherein the P2P channels of the terminal include: P2P channels waiting to be established, P2P channels being established, and P2P channels that have been established; when the number of P2P channels of the terminal does not exceed the first channel number threshold, the target device is directly added to the head of the waiting queue, and a P2P channel is established between the target device at the head of the queue and the terminal; and / or, when the number of P2P channels of the terminal exceeds the first channel number threshold, after terminating one or more P2P channels from the P2P channels of the terminal, the target device is added to the head of the waiting queue, and a P2P channel is established between the target device at the head of the queue and the terminal. The first channel number threshold may refer to the upper limit of the number of P2P channels of the terminal under the constraints of factors such as terminal performance. By comparing the number of P2P channels of the terminal with the first channel number threshold of the terminal, the number of P2P channels can be reasonably controlled, the system crash or delay caused by resource exhaustion can be reduced, and the required P2P channels can be established in a timely manner by conditional queue interruption. By terminating one or more P2P channels from the P2P channels of the terminal when the first channel number threshold is exceeded, and adding the target device to the head of the waiting queue, resources can be allocated to target devices with higher requirements, realizing reasonable resource scheduling under limited resource conditions.

[0038] As an optional embodiment, when terminating one or more P2P channels from the P2P channels of the above terminal, it is possible to select which P2P channel to terminate according to a certain priority rule. For example, the priority of the P2P channel of the above terminal can be determined according to the following factors: whether it is a P2P channel waiting to be established, whether it is a P2P channel being established, whether it is a P2P channel that has been established, and the usage time of the P2P channel after it has been established; from the P2P channels of the above terminal, one or more P2P channels with a low priority are selected to terminate. Among them, the P2P channel waiting to be established is only in the waiting queue and has not started the establishment process, so it has the lowest priority; the P2P channel being established has invested a certain amount of resources to establish it. If the P2P channel being established is terminated, it will cause a waste of resources invested in the early stage, so it has a medium priority; the P2P channel that has been established can be used for data transmission immediately. Once the P2P channel that has been established is terminated, when the P2P channel is needed again, it can only be re-established, which takes a long time to wait and consumes a lot of resources, so it has the highest priority; in the P2P channel that has been established, the usage time can be used as the basis for priority adjustment. For the P2P channel that has been established but has not been used for a long time, because it no longer meets the current immediate needs of the user and occupies resources and affects the establishment of new channels, its priority can be reduced. In addition, when determining the priority of the P2P channel and selecting the end of the low-priority channel, you can choose to end one or more P2P channels with the lowest priority, or you can choose to end one or more P2P channels with a lower priority, so as to achieve the effect of flexible processing according to the actual usage situation, and can meet the needs of the target device while avoiding improper impact on the devices in use or other high-demand devices.

[0039] As an optional embodiment, when establishing the P2P channel between the target device at the head of the queue and the terminal, when resources are sufficient or reserved, the P2P channel between the target device at the head of the queue and the terminal can be directly established after the target device joins the head of the waiting queue. However, terminal resources are usually limited, so it can be first determined whether the number of the P2P channels being established exceeds the second channel number threshold; when the number of the P2P channels being established does not exceed the second channel number threshold, the P2P channel between the target device at the head of the queue and the terminal is directly established; and / or, when the number of the P2P channels being established exceeds the second channel number threshold, after terminating one or more P2P channels from the P2P channels being established, the P2P channel between the target device at the head of the queue and the terminal is established. Among them, due to limited terminal resources, the number of P2P channels that are allowed to be in the state of being established at the same time is limited, and the second channel number threshold can be the upper limit of the number of P2P channels that the terminal allows to be in the state of being established at the same time, and the second channel number threshold can also be set according to the network environment, user needs, application scenarios, etc. Ending one or more P2P channels can be to end any one or more P2P channels of non-target devices, or to end one or more P2P channels with low priority after sorting according to priority. By comparing the number of P2P channels currently being established by the terminal with the set second channel number threshold, and taking action to end one or more P2P channels to release resources when the number exceeds the threshold, resource overload can be avoided and the success rate of channel establishment can be improved. It can not only ensure the stability of key channels, but also ensure that target devices receive priority responses, and achieve the effect of instant establishment of P2P channels through conditional queue interruption.

[0040] As an optional embodiment, when establishing a P2P channel between the target device at the head of the queue and the terminal, if the establishment of the P2P channel fails, a retry to establish the connection can be performed. The number of retries can be set according to the application scenario and terminal performance. If the P2P channel is successfully established within the number of retries, the P2P channel is used normally to transmit information. If the establishment is still unsuccessful after reaching the upper limit of the number of retries, the P2P channel is terminated. For example, when the number of retries is set to 3 times, if the second retry is successful, the P2P channel is used normally to transmit information. If the establishment fails after 3 retries, no more retries are performed and the P2P channel is terminated. By setting the number of P2P channel retries, the chance of successfully establishing a P2P channel can be increased, while avoiding consuming too many resources on failed attempts, thereby achieving a balance between the success rate of P2P channel establishment and system performance.

[0041] As an optional embodiment, after the queue is interrupted to establish the P2P channel between the target device and the terminal, the channel status of the P2P channel between the target device and the terminal can also be monitored; when the channel status is invalid, the P2P channel between the target device and the terminal is terminated. By monitoring the status of the established P2P channel and terminating the channel in time when the channel is invalid, it can be avoided that the device still attempts to use the invalid P2P channel to pull the video stream, reduce delays and timeouts, and can also release the resources occupied by the invalid P2P channel in time, reallocate resources, and improve resource utilization.

[0042] As an optional embodiment, the method of this embodiment can also be applied to the establishment of a P2P channel for each window in multi-screen mode. In multi-screen mode, the terminal can watch multiple videos from multiple target devices through multiple windows at the same time. For each window, the method of the above embodiment can be applied to establish a P2P channel between the target device and the terminal. Among them, the multi-screen mode occupies more resources when playing videos, so the number of P2P channels that the terminal allows to be in the establishment state at the same time in the multi-screen mode will decrease, that is, the second channel number threshold of the multi-screen mode will decrease, and the specific second channel number threshold can be set according to the number of windows in the multi-screen mode. For example, when the number of windows is 1 window, the number of P2P channels that the terminal allows to be in the establishment state at the same time is 4, and the second channel number threshold can be set to 4; when the number of windows is 6, due to the increase in the number of windows, the resources allocated to the establishment of the P2P channel are compressed, and the second channel number threshold can be set to 1. By adjusting the second channel number threshold, resource allocation can be kept consistent with actual usage requirements. By applying the above method to establish a P2P channel for each window in multi-screen mode, the flexibility and adaptability of the terminal can be improved to meet different scenarios and requirements, and the stability and efficiency of the terminal when handling complex situations can be guaranteed.

[0043] Through the above steps, by using the method of queue-jumping to establish the P2P channel between the target device and the terminal, the P2P channel between the device corresponding to the video the user wants to watch and the terminal can be quickly established, reducing the waiting time. By setting the first channel number threshold and the second channel number threshold, and ending other P2P channels with low priority, when the number of P2P channels of the terminal reaches the upper limit, the user's needs can still be quickly responded to.

[0044] In combination with the above-mentioned embodiments and optional embodiments, an optional implementation mode is provided. In this optional implementation mode, a P2P fast queue jumping method is proposed, taking the terminal as a mobile phone and the device as a camera as an example. Even if the number of P2P channels of the mobile phone reaches the upper limit, when the user slides the list or clicks play to select a live camera for which a P2P channel has not been established, the P2P channel can be quickly established. Among them, when the mobile phone has multiple APPs for watching the video of the camera, a P2P channel can be established between each mobile phone APP and each camera respectively. In addition, dynamic adjustment allows the number of P2P channel penetrations to be performed simultaneously, increases the detection of the effectiveness of the P2P channel, and can reduce the CPU usage of the mobile phone. Figure 2 is a schematic diagram of a P2P fast queue-jumping method according to an optional implementation mode of the present invention, such as Figure 2 As shown, the method includes the following processing.

[0045] S1, select camera to view real-time images.

[0046] Selecting a camera includes two aspects: First, on the device list page, first slide the list, then stop sliding, and immediately establish a P2P channel for the devices within the visible range that have not successfully established a P2P channel. Second, when the user clicks on one or several devices to play, immediately start to establish a P2P channel for the devices that have not successfully established a P2P channel. It should be noted that the above method of selecting a camera is only an example, and other methods of selecting a camera can also be applied to this application, which will not be given one by one here.

[0047] S2, determining the state of the P2P channel between the selected camera and the mobile phone.

[0048] If the camera has successfully established a P2P channel, the P2P channel is directly used to transmit the video stream. If the camera is in the process of establishing a P2P channel, the P2P channel is used to transmit the video stream after the penetration is successful. If the camera has not established a P2P channel, step S3 is performed.

[0049] S3, determining whether the number of P2P channels of the mobile phone has reached an upper limit.

[0050] If the number of P2P channels has not reached the upper limit, the P2P channel will be directly established, the P2P channel will be marked as high priority, and added to the head of the waiting queue to wait for the P2P channel to penetrate.

[0051] If the number of P2P channels has reached the upper limit, according to the priority rule (waiting to penetrate the P2P channel < the P2P channel that the device not currently selected by the user is penetrating < the P2P channel that has been successfully penetrated but has not been used for the longest time), a low-priority P2P channel is ended, and then a P2P channel is established for the device selected by the user, marked with a high priority, and added to the head of the waiting queue to wait for P2P penetration.

[0052] S4, prioritize the P2P channels waiting to be penetrated.

[0053] When multiple selected cameras are added to the head of the waiting queue, the multiple selected cameras at the head of the queue are sorted according to the rule that under the same priority, the Network Video Recorder (NVR) device is higher than the Internet Protocol Camera (IPC) device. Since the NVR device plays the role of storing and integrating video streams in the security system, it is responsible for receiving video streams from multiple IPC devices, storing, managing, and later retrieving and playing back. Users may be more inclined to view the video stream integrated by the NVR device rather than the video of a single IPC device. Therefore, setting the P2P channel priority of the NVR device higher than that of the IPC device can ensure the efficient and stable operation of the video surveillance system and meet the user's demand for high-quality, continuous video streams.

[0054] S5, determining whether the number of P2P channels being penetrated has reached a preset upper limit.

[0055] If the upper limit is not reached, the P2P channel at the front of the queue will be penetrated. If the upper limit is reached, one P2P channel that is not currently selected by the user will be terminated, and the P2P channel at the front of the queue will be penetrated. If the P2P channels being penetrated are all the P2P channels currently selected by the user, wait.

[0056] Among them, the above preset upper limit is dynamically adjusted according to the number of playback windows in the playback state. The more playback windows there are, the smaller the upper limit of the number of P2P channel penetrations is set. Dynamically adjusting the upper limit of the number of P2P channel penetrations according to the number of playback windows can reduce CPU usage and improve user experience, especially avoiding freezes in multi-screen mode. For example, the number of P2P channel penetrations allowed to be performed simultaneously in the 1 / 4 / 9 / 16 window playback state can be set to be inconsistent. The more windows there are, the fewer devices are allowed to penetrate simultaneously, so as to balance device performance and user needs.

[0057] S6: For the same camera, if the P2P channel penetration fails, it will try to establish the P2P channel again, and the number of retries is limited to 3 times.

[0058] S7: After the P2P channel is established, add channel availability detection.

[0059] Monitor the P2P channel status. If the P2P channel fails, end the P2P channel.

[0060] It should be noted that in multi-screen mode, the mobile phone will open multiple windows at once, and each window will establish a P2P channel according to steps S1 to S7. In the list state, when the sliding stops, a P2P channel is initiated for each device in the visible range.

[0061] This optional implementation enables the selected device (such as a camera) to quickly start establishing a P2P channel, thereby increasing the chances of users using the P2P channel to pull traffic; controls the number of P2P penetration channels by scenario (multi-screen, list, etc.) to improve user experience; sets the number of P2P channel retries and P2P channel failure detection to improve the success rate of P2P streaming and user experience.

[0062] In addition, the upper limit of the number of P2P channels and the upper limit of the number of P2P channels that can be penetrated simultaneously can be increased by increasing the hardware configuration, so that most P2P channels can remain valid and the frequent destruction and establishment of P2P channels can be reduced, thereby maintaining more P2P channels and using P2P to pull traffic more frequently, improving user experience.

[0063] According to an embodiment of the present invention, a P2P channel establishment device is provided. Figure 3 is a structural block diagram of a P2P channel establishment device according to an embodiment of the present invention. Figure 3 As shown, the device includes: a determination module 302 and an establishment module 304. The device is described below.

[0064] The determination module 302 is used to determine the target device to establish a P2P channel with the terminal; the establishment module 304 is connected to the above-mentioned determination module 302, and is used to interrupt the queue to establish a P2P channel between the above-mentioned target device and the above-mentioned terminal when there are multiple devices waiting to establish a P2P channel with the above-mentioned terminal.

[0065] It should be noted here that the above-mentioned determination module 302 and establishment module 304 correspond to steps S102 to S104 in the embodiment, and the instances and application scenarios implemented by multiple modules and corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment.

[0066] As an optional embodiment, the determination module 302 includes: a first determination unit and a second determination unit. The first determination module is used to receive a sliding operation of sliding the device list, and determine that one or more devices displayed when the sliding operation stops are the target devices; the second determination unit is connected to the first determination unit, and is used to receive a selection operation of one or more devices, and determine that the one or more devices selected by the selection operation are the target devices.

[0067] As an optional embodiment, the establishment module 304 includes: an acquisition unit and an establishment unit. The acquisition unit is used to acquire the waiting queue of the plurality of devices waiting to establish a P2P channel with the terminal; the establishment unit is connected to the acquisition unit and is used to add the target device to the head of the waiting queue and establish a P2P channel between the target device at the head of the queue and the terminal.

[0068] As an optional embodiment, the establishment unit includes: a judgment subunit and an establishment subunit. The judgment subunit is used to judge whether the number of P2P channels of the terminal exceeds the first channel number threshold, wherein the P2P channels of the terminal include: P2P channels waiting to be established, P2P channels being established, and P2P channels that have been established; the establishment subunit is connected to the judgment subunit, and is used to directly add the target device to the head of the waiting queue when the number of P2P channels of the terminal does not exceed the first channel number threshold, and establish a P2P channel between the target device at the head of the queue and the terminal; and / or, when the number of P2P channels of the terminal exceeds the first channel number threshold, after terminating one or more P2P channels from the P2P channels of the terminal, add the target device to the head of the waiting queue, and establish a P2P channel between the target device at the head of the queue and the terminal.

[0069] As an optional embodiment, the establishment subunit includes: a determination subunit and an end subunit. The determination subunit is used to determine the priority of the P2P channel of the terminal according to at least one of the following factors: whether it is a P2P channel waiting to be established, whether it is a P2P channel being established, whether it is a P2P channel that has been established, and the usage time of the P2P channel after it has been established; the end subunit is connected to the determination subunit and is used to select one or more P2P channels with low priority from the P2P channels of the terminal to end.

[0070] As an optional embodiment, the establishment subunit further includes: a judgment subunit and an establishment subunit. The judgment subunit is used to judge whether the number of the P2P channels being established exceeds the second channel number threshold; the establishment subunit is connected to the judgment subunit and is used to directly establish the P2P channel between the target device at the head of the queue and the terminal when the number of the P2P channels being established does not exceed the second channel number threshold; and / or, when the number of the P2P channels being established exceeds the second channel number threshold, after terminating one or more P2P channels from the P2P channels being established, establish the P2P channel between the target device at the head of the queue and the terminal.

[0071] As an optional embodiment, the apparatus further includes: a monitoring module and an ending module. The monitoring module is used to monitor the channel state of the P2P channel between the target device and the terminal; the ending module is connected to the monitoring module and is used to end the P2P channel between the target device and the terminal when the channel state is invalid.

[0072] As an optional embodiment, the above device is also applied to establish a P2P channel for each window in a multi-screen mode.

[0073] According to an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned P2P channel establishment methods.

[0074] According to an embodiment of the present invention, an electronic device is provided, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes any one of the above-mentioned P2P channel establishment methods when running.

[0075] According to an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of any one of the above methods are implemented.

[0076] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0077] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0078] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0079] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0080] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0081] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0082] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A P2P channel establishment method, characterized in that: include: Determine the target device with which the terminal is to establish a P2P channel; In the case that there are multiple devices waiting to establish a P2P channel with the terminal, a P2P channel is established between the target device and the terminal by interrupting the queue.

2. The method according to claim 1, characterized in that At least one of the following methods is used to determine the target device with which the terminal is to establish a P2P channel: receiving a sliding operation of sliding a device list, and determining that one or more devices displayed when the sliding operation stops are the target devices; A selection operation on one or more devices is received, and the one or more devices selected by the selection operation are determined to be the target devices.

3. The method according to claim 1, characterized in that When there are multiple devices waiting to establish a P2P channel with the terminal, interrupting the queue to establish a P2P channel between the target device and the terminal includes: Obtaining a waiting queue of the plurality of devices waiting to establish a P2P channel with the terminal; The target device is added to the head of the waiting queue, and a P2P channel is established between the target device at the head of the queue and the terminal.

4. The method according to claim 3, characterized in that The step of adding the target device to the head of the waiting queue and establishing a P2P channel between the target device at the head of the queue and the terminal includes: Determining whether the number of P2P channels of the terminal exceeds a first channel number threshold, wherein the P2P channels of the terminal include: P2P channels waiting to be established, P2P channels being established, and P2P channels that have been established; When the number of P2P channels of the terminal does not exceed the first channel number threshold, directly add the target device to the head of the waiting queue, and establish a P2P channel between the target device at the head of the queue and the terminal; and / or, when the number of P2P channels of the terminal exceeds the first channel number threshold, after terminating one or more P2P channels from the P2P channels of the terminal, add the target device to the head of the waiting queue, and establish a P2P channel between the target device at the head of the queue and the terminal.

5. The method according to claim 4, characterized in that The step of terminating one or more P2P channels from the P2P channels of the terminal includes: Determine the priority of the P2P channel of the terminal according to the following factors: whether it is a P2P channel waiting to be established, whether it is a P2P channel being established, whether it is a P2P channel that has been established, and the usage time of the P2P channel that has been established; From the P2P channels of the terminal, one or more P2P channels with a low priority are selected to be terminated.

6. The method according to claim 4, characterized in that The establishing of a P2P channel between the target device at the head of the queue and the terminal comprises: Determining whether the number of the P2P channels being established exceeds a second channel number threshold; When the number of the P2P channels being established does not exceed the second channel number threshold, directly establish a P2P channel between the target device at the head of the team and the terminal; and / or, when the number of the P2P channels being established exceeds the second channel number threshold, after terminating one or more P2P channels from the P2P channels being established, establish a P2P channel between the target device at the head of the team and the terminal.

7. The method according to claim 1, characterized in that After the queue interruption establishes a P2P channel between the target device and the terminal, the method further includes: Monitoring the channel status of the P2P channel between the target device and the terminal; When the channel status is invalid, the P2P channel between the target device and the terminal is terminated.

8. A P2P channel establishment device, characterized in that: include: A determination module, used to determine a target device with which a P2P channel is to be established; The establishing module is used to interrupt the queue to establish the P2P channel between the target device and the terminal when there are multiple devices waiting to establish the P2P channel with the terminal.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute the P2P channel establishment method according to any one of claims 1 to 7.

10. An electronic device, characterized in that: include: A memory storing an executable program; A processor is used to run the program, wherein the program executes the P2P channel establishment method according to any one of claims 1 to 7 when running.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.