/// <summary> /// Encode session description object. /// </summary> /// <param name="sessionDescription">Session description object.</param> /// <returns>Encoded SDP.</returns> public static string Encode(this SessionDescription sessionDescription) { StringBuilder sb = new StringBuilder(); // v - protocol version sb.AppendSdpField(sessionDescription.Version); // o - originator sb.AppendSdpField(sessionDescription.Origin); // s - session name sb.AppendSdpField(sessionDescription.SessionName); // c - connection data sb.AppendSdpField(sessionDescription.ConnectionData); // b - bandwith sb.AppendSdpField(sessionDescription.Bandwidth); // t - timming sb.AppendSdpField(sessionDescription.Timing); // a - session aatributes sb.AppendSdpField(sessionDescription.SessionAttributes); // m - media sb.AppendSdpField(sessionDescription.Media); return(sb.ToString()); }
public override void Start() { if (m_RtpClient != null) { return; } base.Start(); //Remove JPEG Track SessionDescription.RemoveMediaDescription(0); m_RtpClient.TransportContexts.Clear(); //Add a MediaDescription to our Sdp on any available port for RTP/AVP Transport using the given payload type SessionDescription.Add(new Sdp.MediaDescription(Sdp.MediaType.audio, 0, Rtp.RtpClient.RtpAvpProfileIdentifier, 96)); //Add the control line SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=control:trackID=1")); //Should be a field set in constructor. //sampling=RG+B; depth=5; colorimetry=SMPTE240M SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=rtpmap:" + SessionDescription.MediaDescriptions.First().MediaFormat + " iLBC/" + ClockRate)); //should allow fmtp:XX mode=YY m_RtpClient.TryAddContext(new Rtp.RtpClient.TransportContext(0, 1, sourceId, SessionDescription.MediaDescriptions.First(), false, sourceId)); }
public void SendOfferSdp(SessionDescription _sessionDescriotion) { executor.Execute(async() => { if (App.HubConnection.State != HubConnectionState.Connected)//(State != ConnectionState.Connected) { ReportError("Sending offer SDP in non connected state."); return; } var json = SignalingMessage.CreateJson(_sessionDescriotion); //SendPostMessage(MessageType.Message, messageUrl, json); //TODO : SignalR SDPOffer Method var isOfferSent = await App.HubConnection.InvokeAsync <string>("SendOfferMessage", json); //TODO : Here, the you call a method in the SignalR Hub passing in a List of clients you want to call. if (roomConnectionParameters.IsLoopback) { // In loopback mode rename this offer to answer and route it back. var sdpAnswer = new SessionDescription(SdpType.Answer, _sessionDescriotion.Sdp); signalingEvents.OnRemoteDescription(sdpAnswer); } }); }
public override void Start() { if (m_RtpClient != null) { return; } base.Start(); //Remove JPEG Track SessionDescription.RemoveMediaDescription(0); m_RtpClient.TransportContexts.Clear(); //Add a MediaDescription to our Sdp on any available port for RTP/AVP Transport using the given payload type SessionDescription.Add(new Sdp.MediaDescription(Sdp.MediaType.video, 0, Rtp.RtpClient.RtpAvpProfileIdentifier, 96)); //Add the control line and media attributes to the Media Description SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=control:trackID=1")); SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=rtpmap:96 H264/90000")); //Sps and pps should be given... SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=fmtp:96 profile-level-id=" + Common.Binary.ReadU24(sps, 4, !BitConverter.IsLittleEndian).ToString("X2") + ";sprop-parameter-sets=" + Convert.ToBase64String(sps, 4, sps.Length - 4) + ',' + Convert.ToBase64String(pps, 4, pps.Length - 4))); m_RtpClient.TryAddContext(new Rtp.RtpClient.TransportContext(0, 1, sourceId, SessionDescription.MediaDescriptions.First(), false, 0)); }
public void AcceptCall() { OK okResponce = new OK(); SessionDescription session = new SessionDescription(); Owner owner = new Owner(); owner.Username = "******"; owner.SessionID = 2890844526; owner.Version = 2890844526; owner.Address = "192.168.0.2"; session.Owner = owner; session.Name = "SIP Call"; Connection connection = new Connection(); connection.Address = "192.168.0.2"; session.Connection = connection; Time time = new Time(0, 0); session.Time.Add(time); Media media1 = new Media(); media1.Type = "audio"; media1.Port = 49170; media1.TransportProtocol = "RTP/AVP"; media1.Attributes.Add("rtpmap", "0 pcmu/8000"); session.Media.Add(media1); okResponce.SessionDescription = session; client.SendResponse(okResponce); }
public override void Start() { if (m_RtpClient != null) { return; } base.Start(); //Remove generic MPEG Track SessionDescription.RemoveMediaDescription(0); m_RtpClient.TransportContexts.Clear(); //Add a MediaDescription to our Sdp on any available port for RTP/AVP Transport using the given payload type SessionDescription.Add(new Sdp.MediaDescription(Sdp.MediaType.video, 0, Rtp.RtpClient.RtpAvpProfileIdentifier, 96)); SessionDescription.Add(new Sdp.MediaDescription(Sdp.MediaType.audio, 0, Rtp.RtpClient.RtpAvpProfileIdentifier, 97)); //Add the control line for video SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=control:trackID=1")); SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=rtpmap:96 MP4V-ES/90000")); //Add the control line for audio SessionDescription.MediaDescriptions.Last().Add(new Sdp.SessionDescriptionLine("a=control:trackID=1")); SessionDescription.MediaDescriptions.Last().Add(new Sdp.SessionDescriptionLine("a=rtpmap:96 MP4A-LATM/90000")); //Should be a field set in constructor. SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("fmtp:96 profile-level-id=1")); SessionDescription.MediaDescriptions.Last().Add(new Sdp.SessionDescriptionLine("fmtp:97 profile-level-id=15; profile=1;")); m_RtpClient.TryAddContext(new Rtp.RtpClient.TransportContext(0, 1, sourceId, SessionDescription.MediaDescriptions.First(), false, sourceId)); m_RtpClient.TryAddContext(new Rtp.RtpClient.TransportContext(2, 3, sourceId, SessionDescription.MediaDescriptions.Last(), false, sourceId)); }
public override void Start() { if (m_RtpClient != null) { return; } base.Start(); //Remove JPEG Track SessionDescription.RemoveMediaDescription(0); m_RtpClient.TransportContexts.Clear(); //Add a MediaDescription to our Sdp on any available port for RTP/AVP Transport using the given payload type SessionDescription.Add(new Sdp.MediaDescription(Sdp.MediaType.video, 0, Rtp.RtpClient.RtpAvpProfileIdentifier, 96)); //Add the control line SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=control:trackID=1")); SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=rtpmap:96 mpeg4-generic/" + ClockRate)); //Should be a field set in constructor. /* * streamType: * The integer value that indicates the type of MPEG-4 stream that is * carried; its coding corresponds to the values of the streamType, * as defined in Table 9 (streamType Values) in ISO/IEC 14496-1. */ SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=fmtp:96 streamtype=3; profile-level-id=1; mode=generic; objectType=2; config=0842237F24001FB400094002C0; sizeLength=10; CTSDeltaLength=16; randomAccessIndication=1; streamStateIndication=4")); m_RtpClient.TryAddContext(new Rtp.RtpClient.TransportContext(0, 1, sourceId, SessionDescription.MediaDescriptions.First(), false, sourceId)); }
public override void Start() { if (m_RtpClient != null) { return; } base.Start(); //Remove JPEG Track SessionDescription.RemoveMediaDescription(0); m_RtpClient.TransportContexts.Clear(); //Add a MediaDescription to our Sdp on any available port for RTP/AVP Transport using the given payload type SessionDescription.Add(new Sdp.MediaDescription(Sdp.MediaType.audio, 0, Rtp.RtpClient.RtpAvpProfileIdentifier, 96)); //Add the control line SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=control:trackID=1")); //Should be a field set in constructor. // a=fmtp:96 cm_unused=ACGHJKNMPTVWXYZ; cm_used=__7F_00-7F_01_01__; j_sec=none /* lazzaro... * a=fmtp:96 j_update=open-loop; cm_unused=ABCFGHJKMQTVWXYZ; * cm_used=__7E_00-7F_09_01.02.03__; * cm_used=__7F_00-7F_04_01.02__; cm_used=C7.64; * ch_never=ABCDEFGHJKMQTVWXYZ; ch_never=4.11-13N; * ch_anchor=P; ch_anchor=C7.64; * ch_anchor=__7E_00-7F_09_01.02.03__; * ch_anchor=__7F_00-7F_04_01.02__; * tsmode=async; linerate=320000; octpos=first (tsmode=buffer; linerate=320000; octpos=last; mperiod=44) (rtp_ptime=0; rtp_maxptime=0) (guardtime=44100) */ SessionDescription.MediaDescriptions.First().Add(new Sdp.SessionDescriptionLine("a=rtpmap:" + SessionDescription.MediaDescriptions.First().MediaFormat + " rtp-midi/" + ClockRate)); m_RtpClient.TryAddContext(new Rtp.RtpClient.TransportContext(0, 1, sourceId, SessionDescription.MediaDescriptions.First(), false, sourceId)); }
/// <summary> /// Changes the profile once the session has been established. /// </summary> /// <param name="newProfile">new profile configuration for the stream</param> /// <returns>An updated session description. If null is returned, the client will have to <see cref="M:Reconnect"/></returns> public SessionDescription SetProfile(Profile newProfile) { SessionDescription newSessionDescription = _proxy.SetProfile(newProfile); if (newSessionDescription != null) { SessionDescription = newSessionDescription; } return(newSessionDescription); }
public SessionDescription SetProfile(Profile profile) { SessionDescription result = null; if (_client != null) { result = _client.SetProfile(profile); } return(result); }
/// <summary> /// Sets the profile on the server. /// </summary> /// <param name="newProfile">the new profile to set</param> /// <seealso cref="T:ITVStream"/> /// <returns>the updated session description</returns> public SessionDescription SetProfile(Profile newProfile) { SessionDescription sd = _proxy.SetProfile(newProfile); if (sd != null) { SessionDescription = sd; } return(sd); }
public override SessionDescription FillOutSessionDescription(OpenGraphRequest openGraphRequest) { SessionDescription sd = base.FillOutSessionDescription(openGraphRequest); sd.TVSessionInfo = new TVSessionInfo(); sd.TVSessionInfo.Channel = this.Channel; sd.TVSessionInfo.TVMode = this.TVMode; sd.TVSessionInfo.ChannelScanInProgress = (channelScanWorker != null) ? channelScanWorker.IsBusy : false; return(sd); }
public override SessionDescription OpenGraph(ClientConnectRequest clientConnectRequest) { SessionDescription sd = base.OpenGraph(clientConnectRequest); Profile newProfile = new Profile(); newProfile.Name = _graph.DefaultProfileName; SetProfile(newProfile); sd.CurrentProfileName = newProfile.Name; return(sd); }
public void OnLocalDescription(SessionDescription sdp) { Executor.Execute(() => { Logger.Debug(TAG, $"Sending {sdp.Type}"); if (IsInitiator) RTCClient?.SendOfferSdp(sdp); else RTCClient?.SendAnswerSdp(sdp); }); }
public BenchmarkSettings() { SessionDescription sd = new SessionDescription(); sd.Origin = new SessionOrigin("-", "1488967357", "1", "IN", "IP4", "91.241.11.242"); sd.ConnectionData = new SessionConnectionData("IN", "IP4", "91.241.11.242"); sd.Timing = new SessionTiming(); sd.AddBandwidth(new SessionBandwidth(BandwithTypes.ApplicationSpecific, 4096)); TestData = sd; }
public void SetRemoteDescription(SessionDescription sdp) { _executor.Execute(() => { if (_peerConnection == null || _isError) { return; } _logger.Debug(TAG, "Set remote SDP."); _peerConnection.SetRemoteDescription(sdp, _observer); }); }
public static SessionDescription GetObject() { SessionDescription sd = new SessionDescription(); sd.Origin = new SessionOrigin("-", "1488967357", "1", "IN", "IP4", "91.241.11.242"); sd.ConnectionData = new SessionConnectionData("IN", "IP4", "91.241.11.242"); sd.Timing = new SessionTiming(0, 0); sd.AddBandwidth(new SessionBandwidth("AS", 64)); return(sd); }
public void Encode_With_Check_Success() { // *** ARRANGE *** SessionDescription sd = new SessionDescription(); sd.Origin = new SessionOrigin("-", "1488967357", "1", "IN", "IP4", "91.241.11.242"); sd.ConnectionData = new SessionConnectionData("IN", "IP4", "91.241.11.242"); sd.Timing = new SessionTiming(); sd.AddBandwidth(new SessionBandwidth(BandwithTypes.ApplicationSpecific, 4096)); // *** ACT *** string result = sd.Encode(); }
public void OnCreateSuccess(SessionDescription origSdp) { outerInstance.RunOnUiThread(() => { outerInstance.logAndToast("Sending " + origSdp.Type); SessionDescription sdp = new SessionDescription(origSdp.Type, outerInstance.preferISAC(origSdp.Description)); JSONObject json = new JSONObject(); jsonPut(json, "type", sdp.Type.CanonicalForm()); jsonPut(json, "sdp", sdp.Description); outerInstance.sendMessage(json); outerInstance.pc.SetLocalDescription(outerInstance.sdpObserver, sdp); }); }
public void OnRemoteDescription(SessionDescription sdp) { Executor.Execute(() => { if (PeerConnectionClient == null) { Logger.Error(TAG, "Received remote SDP for non-initilized peer connection."); return; } PeerConnectionClient.SetRemoteDescription(sdp); }); }
public string ToString(SessionDescription sdp = null) { StringBuilder builder = new StringBuilder(); builder.Append(TimeDescriptionLine.ToString()); foreach (Lines.SessionRepeatTimeLine repeatTime in RepeatLines) { builder.Append(repeatTime.ToString()); } return(builder.ToString()); }
/// <summary> /// Retrieves the response body as a <see cref="SessionDescription"/>. /// </summary> /// <exception cref="SdpParseException">Thrown if the response body cannot be parsed</exception> /// <returns></returns> public SessionDescription GetBodyAsSdp() { if (!HasBody) { throw new SdpParseException("Unable to parse body as SDP, response does not contain a body"); } else if (ContentType != SessionDescription.MIME_TYPE) { throw new SdpParseException($"Response body is not of type '{SessionDescription.MIME_TYPE}'"); } return(SessionDescription.Parse(Encoding.UTF8.GetString(Body))); }
public static ARDSignalingMessage MessageFromJSONString(string json) { var values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); ARDSignalingMessage message = new ARDSignalingMessage(); if (values.ContainsKey("type")) { var type = values["type"] ?? ""; switch (type) { case CandidateType: int.TryParse(values["label"], out int label); var candidate = new IceCandidate(values["candidate"], values["id"], label); message = new ARDICECandidateMessage(candidate); break; case CandidateRemovalType: break; case OfferType: var description = new SessionDescription(SdpType.Offer, values["sdp"]); message = new ARDSessionDescriptionMessage(description); break; case AnswerType: description = new SessionDescription(SdpType.Answer, values["sdp"]); message = new ARDSessionDescriptionMessage(description); break; case PrAnswerType: description = new SessionDescription(SdpType.PrAnswer, values["sdp"]); message = new ARDSessionDescriptionMessage(description); break; case ByeType: message = new ARDByeMessage(); break; default: System.Diagnostics.Debug.WriteLine($"ARDSignalingMessage unexpected type: {type}"); break; } } else { System.Diagnostics.Debug.WriteLine($"ARDSignalingMessage invalid json: {json}"); } return(message); }
/// <summary> /// Returns a session description for a given open graph request /// </summary> /// <param name="openGraphRequest">Open graph request info</param> /// <returns>the SessionDescription that the client will be needing to complete the connection</returns> public virtual SessionDescription FillOutSessionDescription(OpenGraphRequest openGraphRequest) { SessionDescription sd = new SessionDescription(); sd.SourceName = SourceConfig.SourceName; sd.ProfileGroups = ProfileGroups; sd.CurrentProfileName = CurrentProfile.Name; sd.SinkURL = ExpandInterfaceAddressMacro(BaseClientURL, openGraphRequest.InterfaceAddress); AppLogger.Message("Returning SinkURL " + sd.SinkURL); Debug.WriteLine("Returning SinkURL " + sd.SinkURL); sd.StreamTimeLimit = Convert.ToInt32(ConfigurationManager.AppSettings["StreamTimeLimit"]); return(sd); }
public virtual SessionDescription SetProfile(Profile newProfile) { AppLogger.Message("CommonStreamService.SetProfile " + newProfile.Name); #if USE_GLOBAL_GRAPHSERVICELOCK lock (_graphServiceLock) { #endif if (_graph != null) { try { if (newProfile.Name.ToLowerInvariant().Contains("custom")) { CurrentProfile = newProfile; } else { CurrentProfile = _graph.FindProfile(newProfile.Name); } if (CurrentProfile != null) { _graph.ChangeProfile(CurrentProfile); } return(null); } catch (ServerGraphRebuildException exc) { AppLogger.Dump(exc); AppLogger.Message("CommonStreamService.SetProfile() caught ServerGraphRebuildException--opening a new graph"); _graph.Stop(); _graph.State = ServerGraphState.Aborted; _graph.RemoveClient(this); // Save newProfile in the dictionary GraphManager.RemoveAndDisposeGraph(_graph); this.OpenGraphRequest.Profile = CurrentProfile; _graph = OpenGraph(); _graph.AddClient(this); SessionDescription sd = _graph.FillOutSessionDescription(this.OpenGraphRequest); return(sd); } } else { throw new ServiceHasNoGraphException(); } #if USE_GLOBAL_GRAPHSERVICELOCK } #endif }
public override SessionDescription OpenGraph(ClientConnectRequest clientConnectRequest) { SessionDescription sd = base.OpenGraph(clientConnectRequest); _callback = OperationContext.Current.GetCallbackChannel <IRecordCallback>(); Debug.Assert(_callback != null); if (_graph.SourceConfig.MaxRecordingChunkMinutes != 0) { _chunkTimer = new System.Timers.Timer(); _chunkTimer.Interval = _graph.SourceConfig.MaxRecordingChunkMinutes * 1000 * 60; // MaxRecordingChunk _chunkTimer.Elapsed += new System.Timers.ElapsedEventHandler(ChunkTimer_Elapsed); _chunkTimer.Enabled = false; } return(sd); }
//Todo, Most parse header functions could be changed to use a ParseHeader function which gives an array of values which can then be parsed further. //Create header would do the reverse. //internal static string CreateHeader(string key, string value) => key + ':' + CreateHeaderValue(";", value); //internal static string CreateHeaderValue(string sep, params string[] values) //{ // return string.Join(sep, values); //} //Something like this for the reverse //string[] ParseHeaderValues(string delemit, string source) => source.Split(delemit); //string[] ParseHeaderValues(int count) => source.Split(delemit, count); /// <summary> /// Parses a RFCXXXX range string often used in SDP to describe start and end times. /// </summary> /// <param name="value"></param> /// <param name="type"></param> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> public static bool TryParseRange(string value, out string type, out TimeSpan start, out TimeSpan end) { foreach (string part in value.Split((char)ASCII.SemiColon)) { if (SessionDescription.TryParseRange(value, out type, out start, out end)) { return(true); } } type = string.Empty; start = end = Media.Common.Extensions.TimeSpan.TimeSpanExtensions.InfiniteTimeSpan; return(false); }
public void SendAnswerSdp(SessionDescription sdp) { _executor.Execute(() => { if (_connectionParameters.IsLoopback) { _logger.Error(TAG, "Sending answer in loopback mode."); return; } var json = SignalingMessage.CreateJson(sdp); _wsClient.Send(json); }); }
public RTSPDeviceControl(StreamSourceInfo streamSourceInfo, String serverAddress) { _sourceInfo = streamSourceInfo; _sessionDescription = new SessionDescription(); _sessionDescription.SinkURL = _sourceInfo.SinkAddress; Profile profile = new Profile(); profile.Name = "RTSP:RTSP"; ProfileGroup profileGroup = new ProfileGroup(); profileGroup.Name = "RTSP"; profileGroup.Items.Add(profile); ProfileGroups profileGroups = new ProfileGroups(); profileGroups.Items.Add(profileGroup); _sessionDescription.ProfileGroups = profileGroups; _sessionDescription.CurrentProfileName = "RTSP:RTSP"; }
public void SendOfferSdp(SessionDescription sdp) { _executor.Execute(() => { if (State != ConnectionState.Connected) { ReportError("Sending offer SDP in non connected state."); return; } var offerMessage = new SessionDescriptionMessage(sdp) { SocketId = _socketId, MessageType = SignalingMessageType.Offer }; _wsClient.Send(offerMessage.ToJson()); }); }
public UpdateSdp(string origin, string destination, SessionDescription description) { this.origin = origin; this.destination = destination; sdp = description; }
static void Main(string[] args) { // actions, for setLocalDescription/setRemoteDescription const ushort SDP_OFFER = 0x100; const ushort SDP_PRANSWER = 0x200; const ushort SDP_ANSWER = 0x300; // PeerConnection state const ushort NEW = 0; // initial state const ushort OPENING = 1; // local or remote desc set const ushort ACTIVE = 2; // local and remote desc set const ushort CLOSED = 3; // ended state // ICE state const ushort ICE_GATHERING = 0x100; const ushort ICE_WAITING = 0x200; const ushort ICE_CHECKING = 0x300; const ushort ICE_CONNECTED = 0x400; const ushort ICE_COMPLETED = 0x500; const ushort ICE_FAILED = 0x600; const ushort ICE_CLOSED = 0x700; /*NetTransport transport = new NetTransport(); transport.OnEvent += (type, data) => { Console.WriteLine("transport.OnEvent({0}, {1})", type, data); }; transport.SetDomain("sip2sip.info"); Console.WriteLine("Default DstAddr= {0} Dst Port = {1}", transport.defaultDestAddr, transport.defaultDestPort); transport.Start(0); transport.SendTo("salut", "192.168.0.10", 5060); transport.Stop();*/ PeerConnection peerConnection = new PeerConnection(); String ro = peerConnection.createAnswer(true, true); SessionDescription sdpOffer = new SessionDescription(); sdpOffer.Init(ro); Console.WriteLine("Offer before ICE = {0}", sdpOffer.toSdp()); peerConnection.IceCallback += (media, candidate, moreToFollow) => { sdpOffer.addCandidate(media, candidate); if (!moreToFollow) { String sdp = sdpOffer.toSdp(); Console.WriteLine("Offer after ICE = {0}", sdp); peerConnection.setRemoteDescription(SDP_ANSWER, sdp); } }; peerConnection.startIce(0, 0); Console.ReadLine(); peerConnection.close(); }