Disclosure of Invention
The present invention is based on the above problems, and provides a new technical solution, which can realize real-time transmission of media stream when acquiring the media stream.
In view of this, a first aspect of the present invention provides a method for real-time transmission of a media stream, which is used for a SIP (Session Initiation Protocol) server, and includes: respectively registering a media stream receiving end, a media server and a media stream sending end to the SIP server; receiving a first invite message sent by the media stream receiving end, where the first invite message includes a first SDP (Service design package) message body describing media stream information; sending a second invite message to the media server to receive a first 200OK response sent from the media server, wherein the first 200OK response comprises: a second SDP message body describing parameter information of the media stream received by the media server; sending a third invite message to the media streaming sender, where the third invite message includes the second SDP message body, so as to receive a second 200OK response returned by the media streaming sender, and the second 200OK response includes: a third SDP message body describing parameter information of the media stream sent by the media stream sending end; sending a first ACK request to the media server sending end and sending a second ACK request to the media stream sending end to complete establishment of session connection between the media server and the media stream sending end, wherein the first ACK request includes the third SDP message body; and establishing session connection between the media stream receiving end and the media server.
In the technical scheme, the session connection between the media server and the media stream sending end is established, so that the media stream can be transmitted between the media server and the media stream sending end in real time, and the session connection between the media stream receiving end and the media server is established, so that the media stream can be transmitted between the media stream receiving end and the media server in real time, and therefore the media stream collected by the media stream sending end can be transmitted to the media stream receiving end in real time for playing, and the requirement of a user on the real-time transmission of the streaming media is met.
In the foregoing technical solution, preferably, the step of establishing a session connection between the media stream receiving end and the media server further includes: adding an SSRC value to the first invite message and forwarding the SSRC value to the media server so as to receive a third 200OK response returned by the media server, wherein the third 200OK response comprises: a fourth SDP message body describing parameter information of the media stream sent by the media server; forwarding the third 200OK response to the media stream receiving end to receive a third ACK request sent by the media stream receiving end; forwarding the third ACK request to the media server.
In the technical scheme, the session connection between the media stream receiving end and the media server is established, so that the media stream can be transmitted between the media stream receiving end and the media server in real time, and the reliability of the real-time transmission of the stream media is ensured.
In any of the above technical solutions, preferably, the session connection between the media stream receiving end and the media server is established in a proxy manner of B2 BUA.
In the technical scheme, the session connection between the media stream receiving end and the media server is established in a proxy mode of B2BUA (Back-to-Back User Agent), so that the media stream receiving end and the media server can be efficiently and reliably subjected to division and cooperation, and the efficiency of media stream transmission is improved.
In any of the above technical solutions, preferably, after the step of establishing the session connection between the media stream receiving end and the media server, the method further includes: if the BYE message sent by the media stream receiving end or the media stream sending end is received, the session connection between the media server and the media stream sending end is disconnected, and the session connection between the media stream receiving end and the media server is disconnected.
In the technical scheme, the media stream transmission among the media server, the media stream sending end and the media stream receiving end can be disconnected according to the requirements of users.
In any of the above technical solutions, preferably, the step 102 specifically includes: receiving first REGISTER messages respectively sent by the media stream receiving end, the media server and the media stream sending end; respectively sending the encryption modes supported by the SIP server to the media stream receiving end, the media server and the media stream sending end according to the first REGISTER message; receiving second REGISTER messages respectively sent by the media stream receiving end, the media server and the media stream sending end; and acquiring authentication information in an authentication field of the second REGISTER message and a password obtained by encrypting in the encryption mode, respectively verifying the identities of the media stream receiving terminal, the media server and the media stream sending terminal according to the authentication information and the password, and respectively sending a response whether the registration is successful or not to the media stream receiving terminal, the media server and the media stream sending terminal according to a verification result.
In the technical scheme, a media stream receiving end, a media server and a media stream sending end respectively send REGISTER messages twice to an SIP server, a first REGISTER message sent for the first time is used for obtaining an encryption mode supported by the SIP server and encrypting a password through the encryption mode, a second REGISTER message sent for the second time is used for obtaining authentication information and the encrypted password and carrying out identity verification on the media stream receiving end, the media server and the media stream sending end, and registration can be carried out when the identity verification is successful, so that the safety during registration is ensured.
A second aspect of the present invention provides an apparatus for real-time transmission of a media stream, which is used for an SIP server, and includes: a registering unit, configured to register a media stream receiving end, a media server, and a media stream sending end to the SIP server, respectively; a receiving unit, configured to receive a first invite message sent by the media stream receiving end, where the first invite message includes a first SDP body that describes media stream information; a sending unit, configured to send a second invite message to the media server, and the receiving unit is further configured to receive a first 200OK response sent by the media server, where the first 200OK response includes: a second SDP message body describing parameter information of the media stream received by the media server; the sending unit is further configured to send a third invite message to the media stream sending end, where the third invite message includes the second SDP body, and the receiving unit is further configured to receive a second 200OK response returned by the media stream sending end, where the second 200OK response includes: a third SDP message body describing parameter information of the media stream sent by the media stream sending end; the sending unit is further configured to send a first ACK request to the media server sending end, and send a second ACK request to the media stream sending end, so as to complete establishment of a session connection between the media server and the media stream sending end, where the first ACK request includes the third SDP message body; and the establishing unit is used for establishing session connection between the media stream receiving end and the media server.
In the technical scheme, the session connection between the media server and the media stream sending end is established, so that the media stream can be transmitted between the media server and the media stream sending end in real time, and the session connection between the media stream receiving end and the media server is established, so that the media stream can be transmitted between the media stream receiving end and the media server in real time, and therefore the media stream collected by the media stream sending end can be transmitted to the media stream receiving end in real time for playing, and the requirement of a user on the real-time transmission of the streaming media is met.
In the above technical solution, preferably, the establishing unit includes: a forwarding subunit, configured to add an SSRC value to the first invite message and forward the SSRC value to the media server; a first receiving subunit, configured to receive a third 200OK response returned by the media server, where the third 200OK response includes: a fourth SDP message body describing parameter information of the media stream sent by the media server; the forwarding subunit is further configured to forward the third 200OK response to the media stream receiving end; the first receiving subunit is further configured to receive a third ACK request sent by the media stream receiving end; the forwarding subunit is further configured to forward the third ACK request to the media server.
In the technical scheme, the session connection between the media stream receiving end and the media server is established, so that the media stream can be transmitted between the media stream receiving end and the media server in real time, and the reliability of the real-time transmission of the stream media is ensured.
In any of the above technical solutions, preferably, the establishing unit is specifically configured to establish a session connection between the media stream receiving end and the media server in a proxy manner of a B2 BUA.
In the technical scheme, the session connection between the media stream receiving end and the media server is established in a proxy mode of the B2BUA, so that the media stream receiving end and the media server can be efficiently and reliably separated and cooperated, and the efficiency of media stream transmission is improved.
In any of the above technical solutions, preferably, the method further includes: a disconnecting unit, configured to disconnect a session connection between the media server and the media stream sending end and disconnect a session connection between the media stream receiving end and the media server if a BYE message sent by the media stream receiving end or the media stream sending end is received.
In the technical scheme, the media stream transmission among the media server, the media stream sending end and the media stream receiving end can be disconnected according to the requirements of users.
In any one of the above technical solutions, preferably, the registration unit includes: a second receiving subunit, configured to receive first REGISTER messages sent by the media stream receiving end, the media server, and the media stream sending end respectively; a sending subunit, configured to send, according to the first REGISTER message, the encryption mode supported by the SIP server to the media stream receiving end, the media server, and the media stream sending end, respectively; the second receiving subunit is further configured to receive second REGISTER messages sent by the media stream receiving end, the media server, and the media stream sending end respectively; the sending subunit is further configured to acquire authentication information in an authentication field of the second REGISTER message and a password obtained by encrypting in the encryption manner, perform identity verification on the media stream receiving end, the media server, and the media stream sending end according to the authentication information and the password, and send a response indicating whether the registration is successful or not to the media stream receiving end, the media server, and the media stream sending end according to a verification result.
In the technical scheme, a media stream receiving end, a media server and a media stream sending end respectively send REGISTER messages twice to an SIP server, a first REGISTER message sent for the first time is used for obtaining an encryption mode supported by the SIP server and encrypting a password through the encryption mode, a second REGISTER message sent for the second time is used for obtaining authentication information and the encrypted password and carrying out identity verification on the media stream receiving end, the media server and the media stream sending end, and registration can be carried out when the identity verification is successful, so that the safety during registration is ensured.
By the technical scheme of the invention, the real-time transmission of the media stream can be realized when the media stream is collected.
Detailed Description
So that the manner in which the above recited objects, features and advantages of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to the embodiments thereof which are illustrated in the appended drawings. It should be noted that the embodiments and features of the embodiments of the present application may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, however, the present invention may be practiced in other ways than those specifically described herein, and therefore the scope of the present invention is not limited by the specific embodiments disclosed below.
Fig. 1 shows a flow chart of a method for real-time transmission of a media stream according to an embodiment of the invention.
As shown in fig. 1, a method for real-time transmission of a media stream according to an embodiment of the present invention is applied to a SIP server, and includes:
and step 102, registering a media stream receiving end, a media server and a media stream sending end to the SIP server respectively.
Step 104, receiving a first invite message sent by the media stream receiving end, where the first invite message includes a first SDP body describing media stream information.
Step 106, sending a second invite message to the media server to receive a first 200OK response sent by the media server, where the first 200OK response includes: a second SDP message body describing parameter information of media streams received by the media server.
Step 108, sending a third invite message to the media stream sender, where the third invite message includes the second SDP body, so as to receive a second 200OK response returned by the media stream sender, and the second 200OK response includes: and a third SDP message body for describing parameter information of the media stream sent by the media stream sending end.
Step 110, sending a first ACK request to the media server sending end, and sending a second ACK request to the media stream sending end, so as to complete establishment of session connection between the media server and the media stream sending end, where the first ACK request includes the third SDP body.
Step 112, establishing a session connection between the media stream receiving end and the media server.
In the technical scheme, the session connection between the media server and the media stream sending end is established, so that the media stream can be transmitted between the media server and the media stream sending end in real time, and the session connection between the media stream receiving end and the media server is established, so that the media stream can be transmitted between the media stream receiving end and the media server in real time, and therefore the media stream collected by the media stream sending end can be transmitted to the media stream receiving end in real time for playing, and the requirement of a user on the real-time transmission of the streaming media is met.
In the foregoing technical solution, preferably, the step of establishing a session connection between the media stream receiving end and the media server further includes: adding an SSRC value to the first invite message and forwarding the SSRC value to the media server so as to receive a third 200OK response returned by the media server, wherein the third 200OK response comprises: a fourth SDP message body describing parameter information of the media stream sent by the media server; forwarding the third 200OK response to the media stream receiving end to receive a third ACK request sent by the media stream receiving end; forwarding the third ACK request to the media server.
In the technical scheme, the session connection between the media stream receiving end and the media server is established, so that the media stream can be transmitted between the media stream receiving end and the media server in real time, and the reliability of the real-time transmission of the stream media is ensured.
In any of the above technical solutions, preferably, the session connection between the media stream receiving end and the media server is established in a proxy manner of B2 BUA.
In the technical scheme, the session connection between the media stream receiving end and the media server is established in a proxy mode of the B2BUA, so that the media stream receiving end and the media server can be efficiently and reliably separated and cooperated, and the efficiency of media stream transmission is improved.
The B2BUA is a logical entity for implementing session using SIP in communication network, and the B2BUA is used as user agent at both ends of SIP call, and is responsible for processing all SIP signaling at both ends of the call and tracking each call from call establishment to termination.
In any of the above technical solutions, preferably, after the step of establishing the session connection between the media stream receiving end and the media server, the method further includes: if the BYE message sent by the media stream receiving end or the media stream sending end is received, the session connection between the media server and the media stream sending end is disconnected, and the session connection between the media stream receiving end and the media server is disconnected.
In the technical scheme, the media stream transmission among the media server, the media stream sending end and the media stream receiving end can be disconnected according to the requirements of users.
In any of the above technical solutions, preferably, the step 102 specifically includes: receiving first REGISTER messages respectively sent by the media stream receiving end, the media server and the media stream sending end; respectively sending the encryption modes supported by the SIP server to the media stream receiving end, the media server and the media stream sending end according to the first REGISTER message; receiving second REGISTER messages respectively sent by the media stream receiving end, the media server and the media stream sending end; and acquiring authentication information in an authentication field of the second REGISTER message and a password obtained by encrypting in the encryption mode, respectively verifying the identities of the media stream receiving terminal, the media server and the media stream sending terminal according to the authentication information and the password, and respectively sending a response whether the registration is successful or not to the media stream receiving terminal, the media server and the media stream sending terminal according to a verification result.
In the technical scheme, a media stream receiving end, a media server and a media stream sending end respectively send REGISTER messages twice to an SIP server, a first REGISTER message sent for the first time is used for obtaining an encryption mode supported by the SIP server and encrypting a password through the encryption mode, a second REGISTER message sent for the second time is used for obtaining authentication information and the encrypted password and carrying out identity verification on the media stream receiving end, the media server and the media stream sending end, and registration can be carried out when the identity verification is successful, so that the safety during registration is ensured.
The following describes the SIP message in detail, and the SIP message is divided into two types: a request message and a response message. The request message is a message that the SIP client sends to the server side in order to activate a specific operation. The SIP request message in the above scheme includes:
invite message: indicating that a calling user (i.e. the media stream receiving end in the above) initiates a session request to invite other users (i.e. the media stream sending end in the above) to join a session. Or it can be used after call setup for updating the session (here, invite message is also called re-invite message).
And (3) ACK request: indicating that the client has confirmed to the server that it has received a final response to the invite message.
BYE message: indicating that an established call is terminated.
REGISTER message: indicating that the client registers address information listed in the To field with the SIP server.
The SIP response message in the above scheme includes:
200OK response: indicating a successful response.
401Unauthorized response: indicating unauthorized.
The above technical solutions are described in detail below with reference to fig. 2 to 4 (the message format and content in this embodiment both conform to the GB/T28181-2011 standard).
As shown in fig. 2, the system for real-time transmission of media stream includes an SIP server, a media stream receiving end, a media server, a media stream sending end, and a projection screen. The media stream sending end, the SIP server, the media server and the media stream receiving end are connected through the router and the switch. The media stream sending end and the media stream receiving end include but are not limited to: a mobile phone, a PC (Personal Computer), a tablet Computer. The following describes in detail how the SIP server, the media stream receiving end, the media server, the media stream sending end, and the projection screen work to realize real-time transmission of the media stream.
Step one, respectively allocating unique ID, user name and password to a media stream receiving end, a media server and a media stream sending end.
And step two, the media stream receiving end, the media server and the media stream sending end register with the SIP server respectively.
The flows of registering the media stream receiving end, the media server and the media stream sending end to the SIP server are the same, and the following description will take the example that the media stream receiving end registers to the SIP server, as shown in fig. 3 specifically.
1. The media stream receiving end sends a first REGISTER message to the SIP server, where the first REGISTER message does not include an Authorization field (authentication field).
The following is the code implementing step 1.
SIP Server encoding @ destination Domain name or IP Address Port SIP/2.0
Via SIP/2.0/UDP source domain name or IP address port
From < SIP: SIP device code @ source domain name >; tag 185326220
SIP device coding @ source domain name
Call-ID:ms1214-322164710-681262131542511620107-0@172.18.16.3
CSeq:1REGISTER
Contact SIP device code @ source IP address port
Authorization:Capability
algorithm="A:RSA/ECB/PKCS1,RSA/CBC/PKCS1;H:SHA1,MD5,SHA256;S:
DES/ECB/PKCS5,DE
S/CBC/PKCS5,3DES/ECB/PKCS5,3DES/CBC/PKCS5,SCB2"
Max-Forwards:70
Expires:3600
Content-Length:0
2. The SIP server sends a response 401 Unautered response to the media stream receiving end, and gives the encryption mode supported by the SIP server in a message header WWW _ authentication field of the 401 Unautered response.
The following is the code implementing step 2.
SIP/2.0 401Unauthorized
SIP device coding @ source domain name
Content-Length:0
CSeq:1REGISTER
Call-ID:ms1214-322164710-681262131542511620107-0@172.18.16.3
From < SIP: SIP device code @ source domain name >; tag 185326220
Via SIP/2.0/UDP source domain name or IP address port
WWW-Authenticate:Digestrealm="64010000",nonce="6fe9ba44a76be22a"
3. The media stream receiving end sends a second REGISTER request to the SIP server, and authentication information and a password encrypted by using the encryption mode are given in the Authorization field of the second REGISTER request.
The following is the code implementing step 3.
SIP Server encoding @ destination Domain name or IP Address Port SIP/2.0
Via SIP/2.0/UDP source domain name or IP address port
From < SIP: SIP device code @ source domain name >; tag 185326220
SIP device coding @ source domain name
Call-ID:ms1214-322164710-681262131542511620107-0@172.18.16.3
CSeq:2REGISTER
Contact SIP device code @ source IP address port
Authorization:Digest username=
"64010000002020000001",realm="64010000",
nonce="6fe9ba44a76be22a",
uri="sip:64010000002000000001@172.18.16.5:5060",
response="9625d92d1bddea7a911926e0db054968",algorithm=MD5
Max-Forwards:70
Expires:3600
Content-Length:0
4. And the SIP server carries out identity verification on the media stream receiving terminal according to the second REGISTER request, if the identity of the media stream receiving terminal is checked to be legal, a successful 200OK response is sent to the media stream receiving terminal, and if the identity is not legal, a denial of service response is sent.
The following is the code implementing step 4.
SIP/2.0 200OK
To: < SIP device encoding @ source domain name >; tag 69113a2a
Contact SIP device code @ source IP address port
Content-Length:0
CSeq:2REGISTER
Call-ID:ms1214-322164710-681262131542511620107-0@172.18.16.3
From < SIP: SIP device code @ source domain name >; tag 185326220
Via SIP/2.0/UDP source domain name or IP address port
Date:2010-11-02T15:01:26.115
Expires:3600
Step three includes 1-20 steps as shown in fig. 4.
1: the media stream receiving end sends a first invite message to the SIP server, a header field of the first invite message carries a first SDP message body and a Subject field, a field s in the first SDP message body is 'Play' for representing real-time on-demand, and the Subject field indicates parameters of video source ID, resolution, media stream receiving end ID, media stream sequence number and the like of on-demand.
The following is the code implementing step 1.
INVITE SIP media stream sender device code @ destination Domain name or IP Address Port SIP/2.0
To sip media stream sender device coding @ destination domain name
Content-Length byte Length of message entity
Contact sip media stream receiver device code @ source IP address port
CSeq:1INVITE
Call-ID:wlss-f7c53b46-eea27828118c3b50449185980f4bfdf0@
172.20.16.4
Via SIP/2.0/UDP source domain name or IP address
From < sip: media stream recipient device encoding @ source domain name >; tag-e 3719a0b
Subject, media stream sender device code, sending end media stream sequence number, media stream receiver device code, receiving end media stream sequence number
Content-Type:APPLICATION/SDP
Max-Forwards:70
v=0
o=64010600002020000001 0 0IN IP4 172.20.16.3
s=Play
c=IN IP4 172.20.16.3
t=0 0
m=video 6000RTP/AVP 96 98 97
a=recvonly
a=rtpmap:96H264/90000
a=rtpmap:98H264/90000
a=rtpmap:97MPEG4/90000
And after receiving the first invite message, the SIP server establishes session connection between the media server and the media stream sending end through three-party call control. See specifically step 2-step 7 below.
2: and sending a second invite message to the media server, wherein the second invite message does not carry an SDP message body.
The following is the code implementing step 2.
Media Server encoding @ destination Domain name or IP Address Port SIP/2.0
To sip media Server coding @ destination Domain name
Content-Length byte Length of message entity
Contact: < SIP server code @ source IP address port >
CSeq:1INVITE
Call-ID:wlss-11df50d7-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
Via SIP/2.0/UDP source domain name or IP address port
From < SIP: SIP server code @ source domain name >; tag 1ad9931d
Subject, media stream sender device code, sending end media stream sequence number, media stream receiver device
Coding of receiving end media stream sequence number
Max-Forwards:70
3: and after receiving the second invite message of the SIP server, the media server returns a first 200OK response carrying a second SDP message body which describes the contents of IP, ports, media formats and the like of the media stream received by the media server.
The following is the code implementing step 3.
SIP/2.0 200OK
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 1ad9931d
To: < sip: media server coding @ destination domain name >; tag 3094947605
Call-ID:wlss-11df50d7-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
CSeq:1INVITE
Contact: < sip: media server encoding @ destination domain name or IP address port >
Content-Type:APPLICATION/SDP
Content-Length byte Length of message entity
v=0
o=64010000002020000001 0 0IN IP4 172.18.16.3
s=##ms20091214
c=IN IP4 172.18.16.3
t=0 0
m=video 6000RTP/AVP 96 98 97
a=recvonly
a=rtpmap:96H264/90000
a=rtpmap:98H264/90000
a=rtpmap:97MPEG4/90000
4: and after receiving the first 200OK response returned by the media server, the SIP server sends a third invite message to the media stream sending end, wherein the third invite message carries a second SDP message body, the s field is modified to be 'Play' to represent real-time on-demand, the y field is added to describe an SSRC value, and the f field is used to describe media parameters.
The following is the code implementing step 4.
INVITE SIP media stream sender device code @ destination Domain name or IP Address Port SIP/2.0
To sip media stream sender device coding @ destination domain name
Content-Length byte Length of message entity
Contact: < SIP server code @ source IP address port >
CSeq:1INVITE
Call-ID:wlss-e680b2c1-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; f569d024
Content-Type:APPLICATION/SDP
Subject, media stream sender device code, sending end media stream sequence number, media stream receiver device
Coding of receiving end media stream sequence number
Max-Forwards:70
v=0
o=64010000002020000001 0 0IN IP4 172.18.16.3
s=Play
c=IN IP4 172.18.16.3
t=00
m=video 6000RTP/AVP 96 98 97
a=recvonly
a=rtpmap:96H264/90000
a=rtpmap:98H264/90000
a=rtpmap:97MPEG4/90000
y=0100000001
5: and after receiving the third invite message of the SIP server, the media stream sending end returns a second 200OK response, and carries a third SDP message body, wherein the third SDP message body describes the contents of IP, ports, media formats, SSRC fields and the like of the media stream sent by the media stream sending end.
The following is the code implementing step 5.
SIP/2.0 200OK
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; f569d024
To: < sip: media stream sender device code @ destination domain name >; tag 32128
Call-ID:wlss-e680b2c1-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
CSeq:1INVITE
Contact: < sip: media stream sender device code @ destination IP address port >
Content-Type:application/sdp
Content-Length byte Length of message entity
v=0
o=64010000041110000044 0 0IN IP4 172.24.18.44
s=Embedded Net DVR
c=IN IP4 172.24.18.44
t=0 0
m=video 8412RTP/AVP 96 98
a=sendonly
a=rtpmap:96H264/90000
a=rtpmap:98H264/90000
a=username:64010000041110000044
a=password:12345678
y=100000001
6: and after receiving a second 200OK response returned by the media stream sending end, the SIP server sends a first ACK request to the media server, wherein the first ACK request carries a third SDP message body, and the invite session establishment with the media server is completed.
The following is the code implementing step 6.
ACK SIP media Server encoding @ destination Domain name or IP Address Port SIP/2.0
To: < sip: media server coding @ destination domain name >; tag 3094947605
Content-Length byte Length of message entity
CSeq:1ACK
Call-ID:wlss-11df50d7-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 1ad9931d
Content-Type:application/sdp
Max-Forwards:70
v=0
o=64010000041110000044 0 0IN IP4 172.24.18.44
s=Embedded Net DVR
c=IN IP4 172.24.18.44
t=0 0
m=video 8412RTP/AVP 96 98
a=sendonly
a=rtpmap:96H264/90000
a=username:64010000041110000044
a=password:12345678
y=100000001
7: and after receiving a second 200OK response returned by the media stream sending end, the SIP server sends a second ACK request to the media stream sending end, wherein the second ACK request does not carry an SDP message body, and the establishment of the invite session with the media stream sending end is completed.
The following is the code implementing step 7.
ACK SIP media stream sender equipment code @ destination domain name or IP address port SIP/2.0
To: < sip: media stream sender device code @ destination domain name >; tag 32128
Content-Length byte Length of message entity
CSeq:1ACK
Call-ID:wlss-e680b2c1-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; f569d024
Max-Forwards:70
The SIP server establishes a session connection between the media stream receiving end and the media server in a proxy manner of the B2BUA, specifically as the following steps 8 to 12.
8: and adding the SSRC value in the first invite message and forwarding the SSRC value to the media server.
The following is the code implementing step 8.
INVITE SIP media Server encoding @ destination Domain name or IP Address Port SIP/2.0
To sip media Server coding @ destination Domain name
Content-Length byte Length of message entity
Contact: < SIP server code @ source IP address port >
CSeq:1INVITE
Call-ID:wlss-294c2c6e-eea27828118c3b50449185980f4bfdf0@172.18.16.5
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 02f283d7
Subject, media stream sender device code, sending end media stream sequence number, media stream receiver device
Coding of receiving end media stream sequence number
Content-Type:APPLICATION/SDP
Max-Forwards:70
v=0
o=64010600002020000001 0 0IN IP4 172.18.16.3
s=Play
c=IN IP4 172.18.16.3
t=0 0
m=video 6000RTP/AVP 96 98 97
a=recvonly
a=rtpmap:96H264/90000
a=rtpmap:98H264/90000
a=rtpmap:97MPEG4/90000
y=0100000001
9: after receiving the first invite message including the SSRC value, the media server returns a third 200OK response, where the third 200OK response carries a fourth SDP message body, and the fourth SDP message body describes contents of the media server, such as an IP, a port, a media format, and the SSRC value, of a media stream.
The following is the code implementing step 9.
SIP/2.0 200OK
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 02f283d7
To: < sip: media server coding @ destination domain name >; tag 994072228
Call-ID:wlss-294c2c6e-eea27828118c3b50449185980f4bfdf0@172.18.16.5
CSeq:1INVITE
Contact: < sip media server coding @ destination network element IP address port >
Content-Type:APPLICATION/SDP
Content-Length byte Length of message entity
v=0
o=64010000002020000001 0 0IN IP4 172.18.16.1
s=##ms20090428log-restart-callid-ssrc-reinvite
c=IN IP4 172.18.16.1
t=0 0
m=video 6000RTP/AVP 96 98
a=sendonly
a=rtpmap:96H264/90000
a=rtpmap:98H264/90000
a=rtpmap:97MPEG4/90000
y=0100000001
10: the SIP server forwards the third 200OK response to the media stream receiver.
The following is the code in implementing step 10.
SIP/2.0 200OK
To: < sip: media stream sender device code @ destination domain name >; tag 949c43d7
Contact: < sip: media stream sender device code @ destination IP address port >
Content-Length byte Length of message entity
CSeq:1INVITE
Call-ID:wlss-f7c53b46-eea27828118c3b50449185980f4bfdf0@172.20.16.4
Via SIP/2.0/UDP source domain name or IP address
From < sip: media stream recipient device encoding @ source domain name >; tag-e 3719a0b
Content-Type:APPLICATION/SDP
v=0
o=64010000002020000001 0 0IN IP4 172.18.16.1
s=##ms20090428log-restart-callid-ssrc-reinvite
c=IN IP4 172.18.16.1
t=0 0
m=video 6000RTP/AVP 96 98
a=sendonly
a=rtpmap:96H264/90000
a=rtpmap:98H264/90000
a=rtpmap:97MPEG4/90000
y=0100000001
11: and after receiving the third 200OK response, the media stream receiving end replies a third ACK request to complete the invite session establishment with the SIP server.
The following is the code implementing step 11.
ACK SIP media stream sender equipment code @ destination domain name or IP address port SIP/2.0
To: < sip: media stream sender device code @ destination domain name >; tag 949c43d7
Content-Length byte Length of message entity
CSeq:1ACK
Call-ID:wlss-f7c53b46-eea27828118c3b50449185980f4bfdf0@172.20.16.4
Via SIP/2.0/UDP source domain name or IP address
From < sip: media stream recipient device encoding @ source domain name >; tag-e 3719a0b
Max-Forwards:70
12: the SIP server forwards the third ACK request to the media server, and completes the Invite session establishment with the media server.
The following is the code implementing step 12.
ACK SIP media Server encoding @ destination Domain name or IP Address Port SIP/2.0
To: < sip: media server coding @ destination domain name >; tag 994072228
Content-Length byte Length of message entity
CSeq:1ACK
Call-ID:wlss-294c2c6e-eea27828118c3b50449185980f4bfdf0@172.18.16.5
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 02f283d7
Max-Forwards:70
13: and the media stream receiving end sends a BYE message to the SIP server, and disconnects the invite session established in the steps 1, 10 and 11 with the media stream receiving end.
The following is the code implementing step 13.
BYE SIP media stream sender equipment code @ destination domain name or IP address port SIP/2.0
To: < sip: media stream sender device code @ destination domain name >; tag 949c43d7
Content-Length byte Length of message entity
CSeq:2BYE
Call-ID:wlss-f7c53b46-eea27828118c3b50449185980f4bfdf0@172.20.16.4
Via SIP/2.0/UDP source domain name or IP address
From < sip: media stream recipient device encoding @ source domain name >; tag-e 3719a0b
Max-Forwards:70
14: and the SIP server replies a 200OK response after receiving the BYE message, and the session is disconnected.
The following is the code implementing step 14.
SIP/2.0 200OK
Via SIP/2.0/UDP source domain name or IP address
From < sip: media stream recipient device encoding @ source domain name >; tag-e 3719a0b
To: < sip: media stream sender device code @ destination domain name >; tag 949c43d7
Call-ID:wlss-f7c53b46-eea27828118c3b50449185980f4bfdf0@172.20.16.4
CSeq:2BYE
Content-Length byte Length of message entity
15: and the SIP server sends the BYE message to the media server after receiving the BYE message, and disconnects the invite session with the media server established in the steps 8, 9 and 12.
The following is the code implementing step 15.
BYE SIP media Server encoding @ destination Domain name or IP Address Port SIP/2.0
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 02f283d7
To: < sip: media server coding @ destination domain name >; tag 994072228
Call-ID:wlss-294c2c6e-eea27828118c3b50449185980f4bfdf0@172.18.16.5
Content-Length byte Length of message entity
CSeq:2BYE
Max-Forwards:70
16: and the media server replies a 200OK response after receiving the BYE message, and the session is disconnected.
The following is the code implementing step 16.
SIP/2.0 200OK
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 02f283d7
To: < sip: media server coding @ destination domain name >; tag 994072228
Call-ID:wlss-294c2c6e-eea27828118c3b50449185980f4bfdf0@172.18.16.5
GB/T 28181-2011
CSeq:2BYE
Content-Length byte Length of message entity
17: and the SIP server sends a BYE message to the media server, and disconnects the invite session established in the steps 2, 3 and 6 with the media server.
The following is the code implementing step 17.
BYE SIP media Server encoding @ destination Domain name or IP Address Port SIP/2.0
To: < sip: media server coding @ destination domain name >; tag 3094947605
Content-Length byte Length of message entity
CSeq:2BYE
Call-ID:wlss-11df50d7-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 1ad9931d
Max-Forwards:70
18: and the media server replies a 200OK response after receiving the BYE message, and the session is disconnected.
The following is the code that implements step 18.
SIP/2.0 200OK
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; tag 1ad9931d
To: < sip: media server coding @ destination domain name >; tag 3094947605
Call-ID:wlss-11df50d7-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
CSeq:2BYE
Content-Length byte Length of message entity
19: and the SIP server sends a BYE message to the media stream sending end, and disconnects the Invite session established in the steps 4, 5 and 7 with the media stream sending end.
The following is the code in the implementation step 19.
BYE SIP media stream sender equipment code @ destination domain name or IP address port SIP/2.0
To: < sip: media stream sender device code @ destination domain name >; tag 32128
Content-Length byte Length of message entity
CSeq:2BYE
Call-ID:wlss-e680b2c1-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; f569d024
Max-Forwards:70
20: and the media stream sending end replies a 200OK response after receiving the BYE message, and the session is disconnected.
The following is the code in implementing step 20.
SIP/2.0 200OK
Via SIP/2.0/UDP source domain name or IP address
From < SIP: SIP server code @ source domain name >; f569d024
To: < sip: media stream sender device code @ destination domain name >; tag 32128
Call-ID:wlss-e680b2c1-730beb6350a5506aa8316d9dc100cf6b@172.18.16.5
CSeq:2BYE
And fourthly, establishing session connection between the media stream sending end and the media server, and when establishing session connection between the media stream receiving end and the media server, sending the media stream to the media server by the media stream sending end, forwarding the media stream to the media stream receiving end by the server, decoding the media stream by the media stream receiving end through a software decoding library after receiving the media stream, and outputting a decoded Video signal to a projection screen through a Video Graphics Array (VGA).
Fig. 5 is a schematic structural diagram of an apparatus for real-time transmission of a media stream according to an embodiment of the present invention.
As shown in fig. 5, an apparatus 500 for real-time transmission of a media stream according to an embodiment of the present invention is used for a SIP server, and includes: a registering unit 502, a receiving unit 504, a sending unit 506 and a establishing unit 508.
A registering unit 502, configured to register a media stream receiving end, a media server, and a media stream sending end to the SIP server, respectively; a receiving unit 504, configured to receive a first invite message sent by the media stream receiving end, where the first invite message includes a first SDP body describing media stream information; a sending unit 506, configured to send a second invite message to the media server, and the receiving unit 504 is further configured to receive a first 200OK response sent by the media server, where the first 200OK response includes: a second SDP message body describing parameter information of the media stream received by the media server; the sending unit 506 is further configured to send a third invite message to the media stream sending end, where the third invite message includes the second SDP body, and the receiving unit 504 is further configured to receive a second 200OK response returned by the media stream sending end, where the second 200OK response includes: a third SDP message body describing parameter information of the media stream sent by the media stream sending end; the sending unit 506 is further configured to send a first ACK request to the media server sending end, and send a second ACK request to the media stream sending end, so as to complete establishment of a session connection between the media server and the media stream sending end, where the first ACK request includes the third SDP message body; an establishing unit 508, configured to establish a session connection between the media stream receiving end and the media server.
In the technical scheme, the session connection between the media server and the media stream sending end is established, so that the media stream can be transmitted between the media server and the media stream sending end in real time, and the session connection between the media stream receiving end and the media server is established, so that the media stream can be transmitted between the media stream receiving end and the media server in real time, and therefore the media stream collected by the media stream sending end can be transmitted to the media stream receiving end in real time for playing, and the requirement of a user on the real-time transmission of the streaming media is met.
In the foregoing technical solution, preferably, the establishing unit 508 includes: a forwarding subunit 5082, configured to add an SSRC value to the first invite message and forward the SSRC value to the media server; a first receiving sub-unit 5084, configured to receive a third 200OK response returned from the media server, where the third 200OK response includes: a fourth SDP message body describing parameter information of the media stream sent by the media server; the forwarding subunit 5082 is further configured to forward the third 200OK response to the media stream receiving end; the first receiving subunit 5084 is further configured to receive a third ACK request sent from the media stream receiver; the forwarding sub-unit 5082 is further configured to forward the third ACK request to the media server.
In the technical scheme, the session connection between the media stream receiving end and the media server is established, so that the media stream can be transmitted between the media stream receiving end and the media server in real time, and the reliability of the real-time transmission of the stream media is ensured.
In any of the foregoing technical solutions, preferably, the establishing unit 508 is specifically configured to establish a session connection between the media stream receiving end and the media server in a proxy manner of B2 BUA.
In the technical scheme, the session connection between the media stream receiving end and the media server is established in a proxy mode of the B2BUA, so that the media stream receiving end and the media server can be efficiently and reliably separated and cooperated, and the efficiency of media stream transmission is improved.
In any of the above technical solutions, preferably, the method further includes: a disconnecting unit 510, configured to disconnect a session connection between the media server and the media stream sender and disconnect a session connection between the media stream receiver and the media server if a BYE message sent by the media stream receiver or the media stream sender is received.
In the technical scheme, the media stream transmission among the media server, the media stream sending end and the media stream receiving end can be disconnected according to the requirements of users.
In any of the above technical solutions, preferably, the registration unit 502 includes: a second receiving subunit 5022, configured to receive first REGISTER messages sent from the media stream receiving end, the media server, and the media stream sending end respectively; a sending subunit 5024, configured to send, according to the first REGISTER message, the encryption modes supported by the SIP server to the media stream receiving end, the media server, and the media stream sending end, respectively; the second receiving subunit 5022 is further configured to receive second REGISTER messages sent by the media stream receiving end, the media server, and the media stream sending end respectively; the sending subunit 5024 is further configured to obtain authentication information in an authentication field of the second REGISTER message and a password obtained by encrypting in the encryption manner, perform identity verification on the media stream receiving end, the media server, and the media stream sending end according to the authentication information and the password, and send a response indicating whether the registration is successful or not to the media stream receiving end, the media server, and the media stream sending end according to a verification result.
In the technical scheme, a media stream receiving end, a media server and a media stream sending end respectively send REGISTER messages twice to an SIP server, a first REGISTER message sent for the first time is used for obtaining an encryption mode supported by the SIP server and encrypting a password through the encryption mode, a second REGISTER message sent for the second time is used for obtaining authentication information and the encrypted password and carrying out identity verification on the media stream receiving end, the media server and the media stream sending end, and registration can be carried out when the identity verification is successful, so that the safety during registration is ensured.
The technical scheme of the invention is described in detail in the above with reference to the drawings, and the real-time transmission of the media stream can be realized through the technical scheme of the invention.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.