Interface IMediaSession
Offering and Answering SDP messages so that it can be signaled to the other party using the SIPUserAgent.
The implementing class is responsible for ensuring that the client can send media to the other party including creating and managing the RTP streams and processing the audio and video.
Namespace: SIPSorcery.SIP.App
Assembly: SIPSorcery.dll
Syntax
public interface IMediaSession
Properties
| Improve this Doc View SourceHasAudio
Indicates whether the session supports audio.
Declaration
bool HasAudio { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
HasVideo
Indicates whether the session supports video.
Declaration
bool HasVideo { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsClosed
Indicates whether the session has been closed.
Declaration
bool IsClosed { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
RemoteDescription
The SDP description from the remote party describing their audio/video sending and receive capabilities.
Declaration
SDP RemoteDescription { get; }
Property Value
Type | Description |
---|---|
SDP |
RtpBindAddress
Set if the session has been bound to a specific IP address. Normally not required but some esoteric call or network set ups may need.
Declaration
IPAddress RtpBindAddress { get; }
Property Value
Type | Description |
---|---|
System.Net.IPAddress |
Methods
| Improve this Doc View SourceClose(String)
Closes the session. This will stop any audio/video capturing and rendering devices as well as the RTP and RTCP sessions and sockets.
Declaration
void Close(string reason)
Parameters
Type | Name | Description |
---|---|---|
System.String | reason | Optional. A descriptive reason for closing the session. |
CreateAnswer(IPAddress)
Generates an SDP answer to an offer based on the local media tracks. Calling this method does NOT result in any changes to the local tracks. To apply the changes the SetRemoteDescription method must be called.
Declaration
SDP CreateAnswer(IPAddress connectionAddress)
Parameters
Type | Name | Description |
---|---|---|
System.Net.IPAddress | connectionAddress | Optional. If set this address will be used as the SDP Connection address. If not specified the Operating System routing table will be used to lookup the address used to connect to the SDP connection address from the remote offer. |
Returns
Type | Description |
---|---|
SDP | An SDP answer matching the offer and the local media tracks contained in the session. |
CreateOffer(IPAddress)
Creates a new SDP offer based on the local media tracks in the session. Calling this method does NOT change the state of the media tracks. It is safe to call at any time if a session description of the local media state is required.
Declaration
SDP CreateOffer(IPAddress connectionAddress)
Parameters
Type | Name | Description |
---|---|---|
System.Net.IPAddress | connectionAddress | Optional. If set this address will be used as the Connection address in the SDP offer. If not set an attempt will be made to determine the best matching address. |
Returns
Type | Description |
---|---|
SDP | A new SDP offer representing the session's local media tracks. |
SendDtmf(Byte, CancellationToken)
Attempts to send a DTMF tone to the remote party.
Declaration
Task SendDtmf(byte tone, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | tone | The digit representing the DTMF tone to send. |
System.Threading.CancellationToken | ct | A cancellation token that should be set if the DTMF send should be cancelled before completing. Depending on the duration a DTMF send can require multiple RTP packets. This token can be used to cancel any further RTP packets being sent for the tone. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SetMediaStreamStatus(SDPMediaTypesEnum, MediaStreamStatusEnum)
Sets the stream status on all local audio or all video media track.
Declaration
void SetMediaStreamStatus(SDPMediaTypesEnum kind, MediaStreamStatusEnum status)
Parameters
Type | Name | Description |
---|---|---|
SDPMediaTypesEnum | kind | The type of the media track. Must be audio or video. |
MediaStreamStatusEnum | status | The stream status for the media track. |
SetRemoteDescription(SdpType, SDP)
Sets the remote description. Calling this method can result in the local media tracks being disabled if not supported or setting the RTP/RTCP end points if they are.
Declaration
SetDescriptionResultEnum SetRemoteDescription(SdpType sdpType, SDP sessionDescription)
Parameters
Type | Name | Description |
---|---|---|
SdpType | sdpType | Whether the SDP being set is an offer or answer. |
SDP | sessionDescription | The SDP description from the remote party. |
Returns
Type | Description |
---|---|
SetDescriptionResultEnum | If successful an OK enum result. If not an enum result indicating the failure cause. |
Start()
Needs to be called prior to sending media. Performs any set up tasks such as starting audio/video capture devices and starting RTCP reporting.
Declaration
Task Start()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Events
| Improve this Doc View SourceOnRtpClosed
Fired when the RTP channel is closed.
Declaration
event Action<string> OnRtpClosed
Event Type
Type | Description |
---|---|
System.Action<System.String> |
OnRtpEvent
Fired when an RTP event (typically representing a DTMF tone) is detected.
Declaration
event Action<IPEndPoint, RTPEvent, RTPHeader> OnRtpEvent
Event Type
Type | Description |
---|---|
System.Action<System.Net.IPEndPoint, RTPEvent, RTPHeader> |
OnTimeout
Fired when no RTP or RTCP packets are received for a pre-defined period (typically 30s).
Declaration
event Action<SDPMediaTypesEnum> OnTimeout
Event Type
Type | Description |
---|---|
System.Action<SDPMediaTypesEnum> |