protected void TrackChangedSink(AVTransportLastChange sender)
 {
     if (this.OnTrackChanged != null)
     {
         OnTrackChanged(this, sender.CurrentTrack);
     }
 }
 protected void NumberOfTracksChangedSink(AVTransportLastChange sender)
 {
     if (this.OnNumberOfTracksChanged != null)
     {
         OnNumberOfTracksChanged(this, sender.NumberOfTracks);
     }
 }
 protected void PositionSink(AVTransportLastChange sender)
 {
     if (OnPositionChanged != null)
     {
         OnPositionChanged(this, sender.CurrentPosition);
     }
 }
 private void CurrentPlayModeChangedSink(AVTransportLastChange sender)
 {
     if (this.OnCurrentPlayModeChanged != null)
     {
         OnCurrentPlayModeChanged(this, CurrentPlayMode);
     }
 }
        protected void PlayStateSink(AVTransportLastChange sender)
        {
            PlayState state = PlayState.STOPPED;

            switch (sender.PlayState)
            {
            case CpAVTransport.Enum_TransportState.PLAYING:
                state = AVConnection.PlayState.PLAYING;
                break;

            case CpAVTransport.Enum_TransportState.PAUSED_PLAYBACK:
                state = AVConnection.PlayState.PAUSED;
                break;

            case CpAVTransport.Enum_TransportState.PAUSED_RECORDING:
                state = AVConnection.PlayState.PAUSED;
                break;

            case CpAVTransport.Enum_TransportState.STOPPED:
                state = AVConnection.PlayState.STOPPED;
                break;

            case CpAVTransport.Enum_TransportState.TRANSITIONING:
                state = AVConnection.PlayState.TRANSITIONING;
                break;

            case CpAVTransport.Enum_TransportState.RECORDING:
                state = AVConnection.PlayState.RECORDING;
                break;
            }
            OnPlayStateChangedEvent.Fire(this, state);
        }
 protected void TrackURIChangedSink(AVTransportLastChange sender)
 {
     UpdateCurrentItem();
     if (this.OnTrackURIChanged != null)
     {
         OnTrackURIChanged(this);
     }
 }
 protected void URIMetaDataChangedSink(AVTransportLastChange sender)
 {
     if (sender.CurrentURIMetaData != "" && sender.CurrentURIMetaData != "NOT_IMPLEMENTED")
     {
         ArrayList a = MediaBuilder.BuildMediaBranches(sender.CurrentURIMetaData);
         if (a.Count > 0)
         {
             // Since new metadata was evented, we need to update the container, and then
             // update the current item
             _Container = (IMediaContainer)a[0];
             UpdateCurrentItem();
         }
     }
 }
        public AVTransportLastChange(CpAVTransport cpAV, string Ident, int ID, AVTransportLastChange.ReadyHandler ReadyCallback)
        {
            //OpenSource.Utilities.InstanceTracker.Add(this);
            this.OnReady += ReadyCallback;
            InstanceID = ID.ToString();
            Identifier = Ident;
            _cp = cpAV;
            _cp.OnStateVariable_LastChange += new CpAVTransport.StateVariableModifiedHandler_LastChange(LastChangeSink);

            _cp._subscribe(500);

            lock(this)
            {
                if(_cp.HasAction_GetPositionInfo)
                {
                    ++StateCounter;
                    //PollerTimeoutHandler = new LifeTimeMonitor.LifeTimeHandler(PollerTimeoutSink);
                    //PollerTimeout.AddWeakEvent_OnExpired(PollerTimeoutHandler);

                    _cp.GetPositionInfo((UInt32)ID,null,new CpAVTransport.Delegate_OnResult_GetPositionInfo(PositionInfoSink));
                }

                if(_cp.HasAction_GetMediaInfo)
                {
                    ++StateCounter;
                    _cp.GetMediaInfo((UInt32)ID,null,new CpAVTransport.Delegate_OnResult_GetMediaInfo(MediaInfoSink));
                }

                if(_cp.HasAction_GetTransportInfo)
                {
                    ++StateCounter;
                    _cp.GetTransportInfo((UInt32)ID,null,new CpAVTransport.Delegate_OnResult_GetTransportInfo(GetTransportInfoSink));
                }

                if(_cp.HasAction_GetTransportSettings)
                {
                    ++StateCounter;
                    _cp.GetTransportSettings((UInt32)ID,null,new CpAVTransport.Delegate_OnResult_GetTransportSettings(GetTransportSettingsSink));
                }
            }
        }
        /// <summary>
        /// This is called when AVTransportLastChange has acquired state
        /// </summary>
        /// <param name="sender"></param>
        private void AVTLC(AVTransportLastChange sender)
        {
            bool OK = false;

            lock (this)
            {
                --StateCounter;
                if (StateCounter == 0)
                {
                    this.UpdateCurrentItem();
                    OK = true;
                }
            }

            if (OK)
            {
                if (OnReady != null)
                {
                    OnReady(this, Tag);
                }
            }
        }
        public void Dispose()
        {
            AVTransport.Dispose();
            RenderingControl.Dispose();
            ConnectionManager.Dispose();

            this.AV_LastChange.Dispose();
            this.AV_LastChange = null;
            this.RC_LastChange.Dispose();
            this.RC_LastChange = null;
            if(CurrentPlayList!=null)
                CurrentPlayList.Dispose();
            this.CurrentPlayList = null;

            this.OnCurrentMetaDataChanged = null;

            this.OnMediaResourceChanged = null;
            this.OnMute = null;
            this.OnNumberOfTracksChanged = null;

            this.OnPositionChanged = null;
            this.OnReady = null;
            this.OnRemoved = null;

            this.OnTrackChanged = null;
            this.OnTrackURIChanged = null;
            this.OnVolume = null;

            if(OnRemoved!=null) OnRemoved(this);
        }
Beispiel #11
0
		/// <summary>
		/// This is called when AVTransportLastChange has acquired state
		/// </summary>
		/// <param name="sender"></param>
		private void AVTLC(AVTransportLastChange sender)
		{
			bool OK = false;
			lock(this)
			{
				--StateCounter;
				if(StateCounter==0)
				{
					this.UpdateCurrentItem();
					OK = true;
				}
			}

			if(OK)
				if(OnReady!=null) OnReady(this, Tag);
		}
 /// <summary>
 /// This is called when AVTransportLastChange receives an event that this has changed
 /// </summary>
 /// <param name="sender"></param>
 protected void AVTransportURISink(AVTransportLastChange sender)
 {
     this.MediaResource = ResourceBuilder.CreateResource(sender.AVTransportURI, "");
     OnCurrentURIChangedEvent.Fire(this);
     ConnectionManager.GetCurrentConnectionInfo(this.ConnectionID, null, new CpConnectionManager.Delegate_OnResult_GetCurrentConnectionInfo(ConnectionInfoSink));
 }
 protected void TransportStatusChangedSink(AVTransportLastChange sender)
 {
     this.OnTransportStatusChangedEvent.Fire(this, TransportStatus);
 }
Beispiel #14
0
		private void CurrentPlayModeChangedSink(AVTransportLastChange sender)
		{
			if(this.OnCurrentPlayModeChanged!=null)
			{
				OnCurrentPlayModeChanged(this,CurrentPlayMode);
			}
		}
Beispiel #15
0
		protected void URIMetaDataChangedSink(AVTransportLastChange sender)
		{
			
			if(sender.CurrentURIMetaData!="" && sender.CurrentURIMetaData!="NOT_IMPLEMENTED")
			{
				ArrayList a = MediaBuilder.BuildMediaBranches(sender.CurrentURIMetaData);
				if(a.Count>0)
				{
					// Since new metadata was evented, we need to update the container, and then
					// update the current item
					_Container = (IMediaContainer)a[0];
					UpdateCurrentItem();
				}
			}
			
		}
Beispiel #16
0
		protected void TrackChangedSink(AVTransportLastChange sender)
		{
			if(this.OnTrackChanged!=null) OnTrackChanged(this,sender.CurrentTrack);
		}
Beispiel #17
0
		protected void NumberOfTracksChangedSink(AVTransportLastChange sender)
		{
			if(this.OnNumberOfTracksChanged!=null) OnNumberOfTracksChanged(this,sender.NumberOfTracks);
		}
Beispiel #18
0
		protected void TrackURIChangedSink(AVTransportLastChange sender)
		{
			UpdateCurrentItem();
			if(this.OnTrackURIChanged!=null) OnTrackURIChanged(this);
		}
        /// <summary>
        /// This construct is only called by the AVRenderer object.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="AVTransportID"></param>
        /// <param name="RenderingControlID"></param>
        /// <param name="ConnectionID"></param>
        /// <param name="ReadyCallback"></param>
        /// <param name="StateObject"></param>
        internal AVConnection(UPnPDevice device, int AVTransportID, int RenderingControlID, Int32 ConnectionID, AVConnection.OnReadyHandler ReadyCallback, object StateObject)
        {
            OpenSource.Utilities.InstanceTracker.Add(this);
            this.Tag      = StateObject;
            this.OnReady += ReadyCallback;

            FriendlyName = device.FriendlyName;
            Identifier   = device.UniqueDeviceName + ":" + ConnectionID.ToString();
            AVTid        = AVTransportID;
            RCid         = RenderingControlID;
            CMid         = ConnectionID;

            AVTransport       = new CpAVTransport(device.GetServices(CpAVTransport.SERVICE_NAME)[0]);
            RenderingControl  = new CpRenderingControl(device.GetServices(CpRenderingControl.SERVICE_NAME)[0]);
            ConnectionManager = new CpConnectionManager(device.GetServices(CpConnectionManager.SERVICE_NAME)[0]);

            if (RenderingControl.HasStateVariable_Volume)
            {
                // If the renderer has defined ranges, use those
                if (RenderingControl.HasMaximum_Volume)
                {
                    MaxVolume = (UInt16)RenderingControl.Maximum_Volume;
                }
                else
                {
                    MaxVolume = UInt16.MaxValue;
                }

                if (RenderingControl.HasMinimum_Volume)
                {
                    MinVolume = (UInt16)RenderingControl.Minimum_Volume;
                }
                else
                {
                    MinVolume = UInt16.MinValue;
                }
            }

            lock (this)
            {
                if (AVTransport.HasStateVariable_LastChange)
                {
                    // Hook up to the LastChange event of AVTransport
                    ++this.StateCounter;
                    AV_LastChange = new AVTransportLastChange(AVTransport, device.UniqueDeviceName, AVTid, new AVTransportLastChange.ReadyHandler(AVTLC));
                    AV_LastChange.OnCurrentPositionChanged    += new AVTransportLastChange.VariableChangeHandler(PositionSink);
                    AV_LastChange.OnPlayStateChanged          += new AVTransportLastChange.VariableChangeHandler(PlayStateSink);
                    AV_LastChange.OnAVTransportURIChanged     += new AVTransportLastChange.VariableChangeHandler(AVTransportURISink);
                    AV_LastChange.OnCurrentTrackChanged       += new AVTransportLastChange.VariableChangeHandler(TrackChangedSink);
                    AV_LastChange.OnNumberOfTracksChanged     += new AVTransportLastChange.VariableChangeHandler(NumberOfTracksChangedSink);
                    AV_LastChange.OnTrackURIChanged           += new AVTransportLastChange.VariableChangeHandler(TrackURIChangedSink);
                    AV_LastChange.OnCurrentURIMetaDataChanged += new AVTransportLastChange.VariableChangeHandler(URIMetaDataChangedSink);
                    AV_LastChange.OnCurrentPlayModeChanged    += new AVTransportLastChange.VariableChangeHandler(CurrentPlayModeChangedSink);
                    AV_LastChange.OnTransportStatusChanged    += new AVTransportLastChange.VariableChangeHandler(TransportStatusChangedSink);
                }

                if (RenderingControl.HasStateVariable_LastChange)
                {
                    // Hook up to the LastChange event of RenderingControl
                    ++this.StateCounter;
                    RC_LastChange = new RenderingControlLastChange(RenderingControl, device.UniqueDeviceName, RCid, new RenderingControlLastChange.OnReadyHandler(RCLC));
                    RC_LastChange.OnMuteChanged   += new RenderingControlLastChange.VariableChangeHandler(MuteSink);
                    RC_LastChange.OnVolumeChanged += new RenderingControlLastChange.VariableChangeHandler(VolumeSink);
                }

                /* Get ProtocolInfo Value of current connection */
                ++this.StateCounter;
                ConnectionManager.GetCurrentConnectionInfo(ConnectionID, this.GetHashCode(), new CpConnectionManager.Delegate_OnResult_GetCurrentConnectionInfo(InitialState_GetCurrentConnectionInfoSink));
            }
            RenderingControl._subscribe(500);
            AVTransport._subscribe(500);
        }
Beispiel #20
0
		/// <summary>
		/// This construct is only called by the AVRenderer object.
		/// </summary>
		/// <param name="device"></param>
		/// <param name="AVTransportID"></param>
		/// <param name="RenderingControlID"></param>
		/// <param name="ConnectionID"></param>
		/// <param name="ReadyCallback"></param>
		/// <param name="StateObject"></param>
		internal AVConnection(UPnPDevice device, int AVTransportID, int RenderingControlID, Int32 ConnectionID, AVConnection.OnReadyHandler ReadyCallback, object StateObject)
		{
			OpenSource.Utilities.InstanceTracker.Add(this);
			this.Tag = StateObject;
			this.OnReady += ReadyCallback;

			FriendlyName = device.FriendlyName;
			Identifier = device.UniqueDeviceName + ":" + ConnectionID.ToString();
			AVTid = AVTransportID;
			RCid = RenderingControlID;
			CMid = ConnectionID;

			AVTransport = new CpAVTransport(device.GetServices(CpAVTransport.SERVICE_NAME)[0]);
			RenderingControl = new CpRenderingControl(device.GetServices(CpRenderingControl.SERVICE_NAME)[0]);
			ConnectionManager = new CpConnectionManager(device.GetServices(CpConnectionManager.SERVICE_NAME)[0]);

			if(RenderingControl.HasStateVariable_Volume)
			{
				// If the renderer has defined ranges, use those
				if(RenderingControl.HasMaximum_Volume)
				{
					MaxVolume = (UInt16)RenderingControl.Maximum_Volume;
				}
				else
				{
					MaxVolume = UInt16.MaxValue;
				}

				if(RenderingControl.HasMinimum_Volume)
				{
					MinVolume = (UInt16)RenderingControl.Minimum_Volume;
				}
				else
				{
					MinVolume = UInt16.MinValue;
				}
			}
			
			lock(this)
			{
				if(AVTransport.HasStateVariable_LastChange)
				{
					// Hook up to the LastChange event of AVTransport
					++this.StateCounter;
					AV_LastChange = new AVTransportLastChange(AVTransport,device.UniqueDeviceName, AVTid, new AVTransportLastChange.ReadyHandler(AVTLC));
					AV_LastChange.OnCurrentPositionChanged += new AVTransportLastChange.VariableChangeHandler(PositionSink);
					AV_LastChange.OnPlayStateChanged += new AVTransportLastChange.VariableChangeHandler(PlayStateSink);
					AV_LastChange.OnAVTransportURIChanged += new AVTransportLastChange.VariableChangeHandler(AVTransportURISink);
					AV_LastChange.OnCurrentTrackChanged += new AVTransportLastChange.VariableChangeHandler(TrackChangedSink);
					AV_LastChange.OnNumberOfTracksChanged += new AVTransportLastChange.VariableChangeHandler(NumberOfTracksChangedSink);
					AV_LastChange.OnTrackURIChanged += new AVTransportLastChange.VariableChangeHandler(TrackURIChangedSink);
					AV_LastChange.OnCurrentURIMetaDataChanged += new AVTransportLastChange.VariableChangeHandler(URIMetaDataChangedSink);
					AV_LastChange.OnCurrentPlayModeChanged += new AVTransportLastChange.VariableChangeHandler(CurrentPlayModeChangedSink);
					AV_LastChange.OnTransportStatusChanged += new AVTransportLastChange.VariableChangeHandler(TransportStatusChangedSink);
				}

				if(RenderingControl.HasStateVariable_LastChange)
				{
					// Hook up to the LastChange event of RenderingControl
					++this.StateCounter;
					RC_LastChange = new RenderingControlLastChange(RenderingControl,device.UniqueDeviceName, RCid, new RenderingControlLastChange.OnReadyHandler(RCLC));
					RC_LastChange.OnMuteChanged += new RenderingControlLastChange.VariableChangeHandler(MuteSink);
					RC_LastChange.OnVolumeChanged += new RenderingControlLastChange.VariableChangeHandler(VolumeSink);
				}

				/* Get ProtocolInfo Value of current connection */
				++this.StateCounter;
				ConnectionManager.GetCurrentConnectionInfo(ConnectionID,this.GetHashCode(),new CpConnectionManager.Delegate_OnResult_GetCurrentConnectionInfo(InitialState_GetCurrentConnectionInfoSink));
			}
			RenderingControl._subscribe(500);
			AVTransport._subscribe(500);
		}
Beispiel #21
0
		protected void PlayStateSink(AVTransportLastChange sender)
		{
			PlayState state = PlayState.STOPPED;
			switch(sender.PlayState)
			{
				case CpAVTransport.Enum_TransportState.PLAYING:
					state = AVConnection.PlayState.PLAYING;
					break;
				case CpAVTransport.Enum_TransportState.PAUSED_PLAYBACK:
					state = AVConnection.PlayState.PAUSED;
					break;
				case CpAVTransport.Enum_TransportState.PAUSED_RECORDING:
					state = AVConnection.PlayState.PAUSED;
					break;
				case CpAVTransport.Enum_TransportState.STOPPED:
					state = AVConnection.PlayState.STOPPED;
					break;
				case CpAVTransport.Enum_TransportState.TRANSITIONING:
					state = AVConnection.PlayState.TRANSITIONING;
					break;
				case CpAVTransport.Enum_TransportState.RECORDING:
					state = AVConnection.PlayState.RECORDING;
					break;
			}
			OnPlayStateChangedEvent.Fire(this, state);
		}
Beispiel #22
0
		protected void PositionSink(AVTransportLastChange sender)
		{
			if(OnPositionChanged!=null) OnPositionChanged(this,sender.CurrentPosition);
		}
Beispiel #23
0
		/// <summary>
		/// This is called when AVTransportLastChange receives an event that this has changed
		/// </summary>
		/// <param name="sender"></param>
		protected void AVTransportURISink(AVTransportLastChange sender)
		{
			this.MediaResource = ResourceBuilder.CreateResource(sender.AVTransportURI,"");
			OnCurrentURIChangedEvent.Fire(this);
			ConnectionManager.GetCurrentConnectionInfo(this.ConnectionID,null,new CpConnectionManager.Delegate_OnResult_GetCurrentConnectionInfo(ConnectionInfoSink));
		}
Beispiel #24
0
		protected void TransportStatusChangedSink(AVTransportLastChange sender)
		{
			this.OnTransportStatusChangedEvent.Fire(this,TransportStatus);
		}