예제 #1
0
        protected void SeekSink(System.UInt32 InstanceID, DvAVTransport.Enum_A_ARG_TYPE_SeekMode Unit, System.String Target)
        {
            if(ID_Table.ContainsKey(InstanceID)==false)
            {
                throw(new UPnPCustomException(802,InstanceID.ToString() + " is not a valid InstanceID"));
            }
            else
            {
                AVConnection c = (AVConnection)ID_Table[InstanceID];

                if ((c.NumberOfTracks <= 1) && (Unit == DvAVTransport.Enum_A_ARG_TYPE_SeekMode.TRACK_NR))
                {
                    throw new UPnPCustomException(710, "Invalid seek mode. Cannot seek on a zero or one-item playlist or media.");
                }
                c.Seek(Unit,Target);
            }
        }
예제 #2
0
 protected void GetTransportSettingsSink(System.UInt32 InstanceID, out DvAVTransport.Enum_CurrentPlayMode PlayMode, out DvAVTransport.Enum_CurrentRecordQualityMode RecQualityMode)
 {
     if(ID_Table.ContainsKey(InstanceID)==false)
     {
         throw(new UPnPCustomException(802,InstanceID.ToString() + " is not a valid InstanceID"));
     }
     else
     {
         AVConnection c = (AVConnection)ID_Table[InstanceID];
         PlayMode = c._CurrentPlayMode;
         RecQualityMode = c._CurrentRecMode;
     }
 }
예제 #3
0
 protected void PlaySink(System.UInt32 InstanceID, DvAVTransport.Enum_TransportPlaySpeed Speed)
 {
     if(ID_Table.ContainsKey(InstanceID)==false)
     {
         throw(new UPnPCustomException(802,InstanceID.ToString() + " is not a valid InstanceID"));
     }
     else
     {
         AVConnection c = (AVConnection)ID_Table[InstanceID];
         c.Play(Speed);
     }
 }
예제 #4
0
 protected void GetTransportInfoSink(System.UInt32 InstanceID, out DvAVTransport.Enum_TransportState CurrentTransportState, out DvAVTransport.Enum_TransportStatus CurrentTransportStatus, out DvAVTransport.Enum_TransportPlaySpeed CurrentSpeed)
 {
     if(ID_Table.ContainsKey(InstanceID)==false)
     {
         throw(new UPnPCustomException(802,InstanceID.ToString() + " is not a valid InstanceID"));
     }
     else
     {
         AVConnection c = (AVConnection)ID_Table[InstanceID];
         CurrentTransportState = c._CurrentTransportState;
         CurrentSpeed = c._CurrentTransportSpeed;
         CurrentTransportStatus = c._CurrentStatus;
     }
 }
예제 #5
0
        public AVRenderer(int MaxConnections, ProtocolInfoString[] Info, ConnectionHandler h)
        {
            ConnectionMax = MaxConnections;
            OnNewConnection += h;

            InfoStrings = Info;
            device = UPnPDevice.CreateEmbeddedDevice(1,Guid.NewGuid().ToString());
            device.FriendlyName = "AVRenderer Device (" + Dns.GetHostName() +")";

            AVT = new DvAVTransport();
            AVT.GetUPnPService().Major = 1;
            AVT.GetUPnPService().Minor = 0;

            Manager = new DvConnectionManager();
            Manager.GetUPnPService().Major = 1;
            Manager.GetUPnPService().Minor = 0;

            Control = new DvRenderingControl();
            Control.GetUPnPService().Major = 1;
            Control.GetUPnPService().Minor = 0;

            Manager.External_PrepareForConnection = new DvConnectionManager.Delegate_PrepareForConnection(PrepareForConnectionSink);
            Manager.External_ConnectionComplete = new DvConnectionManager.Delegate_ConnectionComplete(ConnectionCompleteSink);
            Manager.External_GetCurrentConnectionIDs = new DvConnectionManager.Delegate_GetCurrentConnectionIDs(GetCurrentConnectionIDsSink);
            Manager.External_GetProtocolInfo = new DvConnectionManager.Delegate_GetProtocolInfo(GetProtocolInfoSink);
            Manager.External_GetCurrentConnectionInfo = new DvConnectionManager.Delegate_GetCurrentConnectionInfo(GetCurrentConnectionInfoSink);

            Manager.Evented_CurrentConnectionIDs = "";
            //Manager.Evented_PhysicalConnections = "";

            string Sink = "";
            foreach(ProtocolInfoString s in InfoStrings)
            {
                if(Sink=="")
                {
                    Sink = s.ToString();
                }
                else
                {
                    Sink = Sink + "," + s.ToString();
                }
            }

            Manager.Evented_SinkProtocolInfo = Sink;
            Manager.Evented_SourceProtocolInfo = "";

            AVT.Accumulator_LastChange = new InstanceID_LastChangeAccumulator("AVT");
            AVT.ModerationDuration_LastChange = 0.5;
            AVT.Evented_LastChange = "&lt;Event xmlns = &quot;urn:schemas-upnp-org:metadata-1-0/AVT/&quot;/&gt;";

            AVT.External_GetMediaInfo = new DvAVTransport.Delegate_GetMediaInfo(GetMediaInfoSink);
            AVT.External_GetPositionInfo = new DvAVTransport.Delegate_GetPositionInfo(GetPositionInfoSink);
            AVT.External_GetTransportInfo = new DvAVTransport.Delegate_GetTransportInfo(GetTransportInfoSink);
            AVT.External_GetTransportSettings = new DvAVTransport.Delegate_GetTransportSettings(GetTransportSettingsSink);
            AVT.External_GetDeviceCapabilities = new DvAVTransport.Delegate_GetDeviceCapabilities(GetDeviceCapabilitiesSink);
            AVT.External_GetCurrentTransportActions = new DvAVTransport.Delegate_GetCurrentTransportActions(GetCurrentTransportActionsSink);

            AVT.External_Play = new DvAVTransport.Delegate_Play(PlaySink);
            AVT.External_Stop = new DvAVTransport.Delegate_Stop(StopSink);
            AVT.External_Pause = new DvAVTransport.Delegate_Pause(PauseSink);
            AVT.External_Record = new DvAVTransport.Delegate_Record(RecordSink);
            AVT.External_Previous = new DvAVTransport.Delegate_Previous(PreviousSink);
            AVT.External_Next = new DvAVTransport.Delegate_Next(NextSink);
            AVT.External_Seek = new DvAVTransport.Delegate_Seek(SeekSink);
            AVT.External_SetAVTransportURI = new DvAVTransport.Delegate_SetAVTransportURI(SetAVTransportURISink);
            AVT.External_SetNextAVTransportURI = new DvAVTransport.Delegate_SetNextAVTransportURI(SetNextAVTransportURISink);
            AVT.External_SetPlayMode = new DvAVTransport.Delegate_SetPlayMode(SetPlayModeSink);
            AVT.External_SetRecordQualityMode = new DvAVTransport.Delegate_SetRecordQualityMode(SetRecordQualityModeSink);
            AVT.External_Record = new DvAVTransport.Delegate_Record(RecordSink);

            Control.Evented_LastChange = "&lt;Event xmlns = &quot;urn:schemas-upnp-org:metadata-1-0/RCS/&quot;/&gt;";

            Control.Accumulator_LastChange = new InstanceID_LastChangeAccumulator("RCS");
            Control.ModerationDuration_LastChange = 1;

            Control.External_GetMute = new DvRenderingControl.Delegate_GetMute(GetMuteSink);
            Control.External_SetMute = new DvRenderingControl.Delegate_SetMute(SetMuteSink);
            Control.External_GetVolume = new DvRenderingControl.Delegate_GetVolume(GetVolumeSink);
            Control.External_SetVolume = new DvRenderingControl.Delegate_SetVolume(SetVolumeSink);
            Control.External_GetBlueVideoBlackLevel  = new DvRenderingControl.Delegate_GetBlueVideoBlackLevel(GetBlueVideoBlackSink);
            Control.External_GetBlueVideoGain = new DvRenderingControl.Delegate_GetBlueVideoGain(GetBlueVideoGainSink);
            Control.External_SetBlueVideoBlackLevel = new DvRenderingControl.Delegate_SetBlueVideoBlackLevel(SetBlueVideoBlackSink);
            Control.External_SetBlueVideoGain = new DvRenderingControl.Delegate_SetBlueVideoGain(SetBlueVideoGainSink);
            Control.External_GetGreenVideoBlackLevel  = new DvRenderingControl.Delegate_GetGreenVideoBlackLevel(GetGreenVideoBlackSink);
            Control.External_GetGreenVideoGain = new DvRenderingControl.Delegate_GetGreenVideoGain(GetGreenVideoGainSink);
            Control.External_SetGreenVideoBlackLevel = new DvRenderingControl.Delegate_SetGreenVideoBlackLevel(SetGreenVideoBlackSink);
            Control.External_SetGreenVideoGain = new DvRenderingControl.Delegate_SetGreenVideoGain(SetGreenVideoGainSink);
            Control.External_GetRedVideoBlackLevel  = new DvRenderingControl.Delegate_GetRedVideoBlackLevel(GetRedVideoBlackSink);
            Control.External_GetRedVideoGain = new DvRenderingControl.Delegate_GetRedVideoGain(GetRedVideoGainSink);
            Control.External_SetRedVideoBlackLevel = new DvRenderingControl.Delegate_SetRedVideoBlackLevel(SetRedVideoBlackSink);
            Control.External_SetRedVideoGain = new DvRenderingControl.Delegate_SetRedVideoGain(SetRedVideoGainSink);
            Control.External_GetBrightness = new DvRenderingControl.Delegate_GetBrightness(GetBrightnessSink);
            Control.External_SetBrightness = new DvRenderingControl.Delegate_SetBrightness(SetBrightnessSink);
            Control.External_GetContrast = new DvRenderingControl.Delegate_GetContrast(GetContrastSink);
            Control.External_SetContrast = new DvRenderingControl.Delegate_SetContrast(SetContrastSink);
            Control.External_GetSharpness = new DvRenderingControl.Delegate_GetSharpness(GetSharpnessSink);
            Control.External_SetSharpness = new DvRenderingControl.Delegate_SetSharpness(SetSharpnessSink);

            Control.External_ListPresets = new DvRenderingControl.Delegate_ListPresets(ListPresetsSink);
            Control.External_SelectPreset = new DvRenderingControl.Delegate_SelectPreset(SelectPresetSink);

            device.Manufacturer = "OpenSource";
            device.ManufacturerURL = "";
            device.PresentationURL = "/";
            device.HasPresentation = false;
            device.ModelName = "Renderer";
            device.ModelDescription = "AV Media Renderer Device";
            device.ModelURL = new Uri("http://www.sourceforge.org");
            device.StandardDeviceType = "MediaRenderer";

            device.AddService(Manager);
            device.AddService(Control);
            device.AddService(AVT);

            if(ConnectionMax == 0)
            {
                Manager.Evented_CurrentConnectionIDs = "0";
                CurrentConnections = 1;
                AVConnection c = new AVConnection(this, "", "/", -1, DvConnectionManager.Enum_A_ARG_TYPE_Direction.INPUT, 0, 0, 0);
                c.Parent = this;
                c._WhoCreatedMe = new IPEndPoint(IPAddress.Parse("127.0.0.1"),0);
                ID_Table[(UInt32)0] = c;
                if(h!=null) h(this,c);
            }
        }
예제 #6
0
 protected void SetRecordQualityModeSink(System.UInt32 InstanceID, DvAVTransport.Enum_CurrentRecordQualityMode NewRecordQualityMode)
 {
     if(ID_Table.ContainsKey(InstanceID)==false)
     {
         throw(new UPnPCustomException(802,InstanceID.ToString() + " is not a valid InstanceID"));
     }
     else
     {
         AVConnection c = (AVConnection)ID_Table[InstanceID];
         c.SetRecordQualityMode(NewRecordQualityMode);
     }
 }
예제 #7
0
        protected void GetMediaInfoSink(System.UInt32 InstanceID, out System.UInt32 NrTracks, out System.String MediaDuration, out System.String CurrentURI, out System.String CurrentURIMetaData, out System.String NextURI, out System.String NextURIMetaData, out DvAVTransport.Enum_PlaybackStorageMedium PlayMedium, out DvAVTransport.Enum_RecordStorageMedium RecordMedium, out DvAVTransport.Enum_RecordMediumWriteStatus WriteStatus)
        {
            if(ID_Table.ContainsKey(InstanceID)==false)
            {
                throw(new UPnPCustomException(802,InstanceID.ToString() + " is not a valid InstanceID"));
            }
            else
            {
                AVConnection c = (AVConnection)ID_Table[InstanceID];
                NrTracks = c._NumberOfTracks;
                MediaDuration = string.Format("{0:00}",c._Duration.Hours) + ":" + string.Format("{0:00}",c._Duration.Minutes) + ":" + string.Format("{0:00}",c._Duration.Seconds);
                if(c._CurrentURI==null)
                {
                    CurrentURI = "";
                }
                else
                {
                    CurrentURI = HTTPMessage.UnEscapeString(c._CurrentURI.AbsoluteUri);
                }
                if(c._NextURI==null)
                {
                    NextURI = "";
                }
                else
                {
                    NextURI = HTTPMessage.UnEscapeString(c._NextURI.AbsoluteUri);
                }

                CurrentURIMetaData = c._CurrentURIMetaData;
                NextURIMetaData = c._NextURIMetaData;
                PlayMedium = c._PlaybackMedium;
                RecordMedium = c._RecordMedium;
                WriteStatus = c._WriteStatus;
            }
        }
예제 #8
0
 internal void SetPlayMode(DvAVTransport.Enum_CurrentPlayMode NewMode)
 {
     CurrentPlayMode = NewMode;
     if(OnCurrentPlayModeChanged!=null) OnCurrentPlayModeChanged(this);
 }
예제 #9
0
 internal void SetRecordQualityMode(DvAVTransport.Enum_CurrentRecordQualityMode NewMode)
 {
     this.CurrentRecordQualityMode = NewMode;
     if(this.OnCurrentRecordQualityModeChanged!=null) this.OnCurrentRecordQualityModeChanged(this);
 }
예제 #10
0
 internal void Seek(DvAVTransport.Enum_A_ARG_TYPE_SeekMode Unit, System.String Target)
 {
     if(OnSeek!=null) OnSeek(this,Unit,Target);
 }
예제 #11
0
 internal void Play(DvAVTransport.Enum_TransportPlaySpeed speed)
 {
     _CurrentTransportSpeed = speed;
     if(OnPlay!=null) OnPlay(this,speed);
 }
예제 #12
0
 internal _DvAVTransport(DvAVTransport n)
 {
     Outer = n;
     S = BuildUPnPService();
 }
예제 #13
0
        protected void SeekSink(AVConnection sender, DvAVTransport.Enum_A_ARG_TYPE_SeekMode SeekMode, string Target)
        {
            if (InvokeRequired) { Invoke(new AVConnection.SeekHandler(SeekSink), sender, SeekMode, Target); return; }

            DText p = new DText();
            p.ATTRMARK = ":";
            p[0] = Target;

            if ((SeekMode == DvAVTransport.Enum_A_ARG_TYPE_SeekMode.REL_TIME) && (this.m_SeekPositionEnabled))
            {
                TimeSpan ts = new TimeSpan(int.Parse(p[1]), int.Parse(p[2]), int.Parse(p[3]));
                player.Ctlcontrols.currentPosition = ts.TotalSeconds;
            }
        }
예제 #14
0
        protected void PlaySink(AVConnection sender, DvAVTransport.Enum_TransportPlaySpeed Speed)
        {
            if (InvokeRequired) { Invoke(new AVConnection.PlayHandler(PlaySink), sender, Speed); return; }

            if (sender.CurrentURI == null)
            {
                player.Ctlcontrols.stop();
                sender.CurrentTransportState = DvAVTransport.Enum_TransportState.STOPPED;
                return;
            }

            if (sender.CurrentTransportState == DvAVTransport.Enum_TransportState.PAUSED_PLAYBACK)
            {
                player.Ctlcontrols.play();
            }
            else
            {
                if (sender.CurrentTransportState != DvAVTransport.Enum_TransportState.PLAYING)
                {
                    if (sender.CurrentURI.LocalPath.EndsWith(".m3u", true, System.Threading.Thread.CurrentThread.CurrentUICulture))
                    {
                        lock (this.m_LockRequest)
                        {
                            sender.CurrentTransportState = DvAVTransport.Enum_TransportState.TRANSITIONING;
                            string mediaUri = sender.CurrentURI.AbsoluteUri.Trim();//.ToLower();
                            if (this.m_PlainM3U.ContainsKey(mediaUri))
                            {
                                player.openPlayer((string)this.m_PlainM3U[mediaUri]);

                                StreamReader sr = System.IO.File.OpenText((string)this.m_PlainM3U[mediaUri]);
                                this.m_M3U = sr.ReadToEnd();

                                sr = System.IO.File.OpenText((string)this.m_Metadata[mediaUri]);
                                this.m_METADATA = sr.ReadToEnd();
                                DetermineMediaDuration(this.m_METADATA);
                            }
                            else
                            {
                                HTTPRequest R = new HTTPRequest();
                                R.OnResponse += new HTTPRequest.RequestHandler(Sink_AcquireAndSetPlaylist);
                                this.PlaylistRequests[R] = sender.CurrentURI.AbsoluteUri.Trim();//.ToLower();
                                this.m_LastRequest = R;
                                try
                                {
                                    R.PipelineRequest(new Uri(mediaUri), sender);
                                }
                                catch
                                {
                                    this.m_LastRequest = null;
                                    this.PlaylistRequests.Remove(R);
                                }
                            }
                        }
                    }
                    else
                    {
                        lock (this.m_LockRequest)
                        {
                            sender.CurrentTransportState = DvAVTransport.Enum_TransportState.TRANSITIONING;
                            player.URL = sender.CurrentURI.ToString();
                            player.Ctlcontrols.play();
                        }
                    }

                }
            }
        }