Ejemplo n.º 1
0
        /// <summary>
        /// Override Equals in order to specify what equality means for devices
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            PlaybackDevice otherDevice = ( PlaybackDevice )obj;

            return((otherDevice.IPAddress == IPAddress) && (otherDevice.DescriptionUrl == DescriptionUrl) &&
                   (otherDevice.Port == Port));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the PlaybackDeviceAvailableMessage message is received
        /// If this is a change then report it
        /// </summary>
        /// <param name="message"></param>
        private static void DeviceAvailable(PlaybackDevice newDevice)
        {
            PlaybackDevice oldDevice = PlaybackManagerModel.AvailableDevice;

            // Check for no new device
            if (newDevice == null)
            {
                // If there was an exisiting availabel device then repoprt this change
                if (oldDevice != null)
                {
                    PlaybackManagerModel.AvailableDevice = null;
                    DataReporter?.SelectPlaybackDevice(oldDevice);
                }
            }
            // If there was no available device then save the new device and report the change
            else if (oldDevice == null)
            {
                PlaybackManagerModel.AvailableDevice = newDevice;
                DataReporter?.SelectPlaybackDevice(oldDevice);
            }
            // If the old and new are different type (local/remote) then report the change
            else if (oldDevice.IsLocal != newDevice.IsLocal)
            {
                PlaybackManagerModel.AvailableDevice = newDevice;
                DataReporter?.SelectPlaybackDevice(oldDevice);
            }
            // If both devices are remote but different then report the change
            else if ((oldDevice.IsLocal == false) && (newDevice.IsLocal == false) && (oldDevice.FriendlyName != newDevice.FriendlyName))
            {
                PlaybackManagerModel.AvailableDevice = newDevice;
                DataReporter?.SelectPlaybackDevice(oldDevice);
            }
        }
 public void Dispose()
 {
     if (PlaybackDevice.DeviceInfo.IsInitialized)
     {
         PlaybackDevice.Dispose();
     }
 }
Ejemplo n.º 4
0
 public void Play()
 {
     if (PlaybackDevice != null && FileStream != null && PlaybackDevice.PlaybackState != PlaybackState.Playing)
     {
         PlaybackDevice.Play();
     }
 }
Ejemplo n.º 5
0
 public void Dispose()
 {
     Stop();
     CloseFile();
     PlaybackDevice?.Dispose();
     PlaybackDevice = null;
 }
        /// <summary>
        /// Get the selected device from the database and if its the local device report is as available
        /// </summary>
        private static void ReportLocalSelectedDevice()
        {
            PlaybackDevice localDevice = PlaybackSelectionModel.RemoteDevices.DeviceCollection[0];

            // Use the Playback class to retrieve the last selected device
            PlaybackSelectionModel.SelectedDeviceName = Playback.PlaybackDeviceName;

            if (PlaybackSelectionModel.SelectedDeviceName.Length == 0)
            {
                // No device selected. Select the local device
                PlaybackSelectionModel.SelectedDeviceName = localDevice.FriendlyName;
                Playback.PlaybackDeviceName = PlaybackSelectionModel.SelectedDeviceName;
            }

            // If the selected device is the local device then report it as available
            if (PlaybackSelectionModel.SelectedDeviceName == localDevice.FriendlyName)
            {
                PlaybackSelectionModel.SelectedDevice = localDevice;
                new PlaybackDeviceAvailableMessage()
                {
                    SelectedDevice = localDevice
                }.Send();
            }

            // Report that the Playback Selection model have changed
            new PlaybackModelChangedMessage().Send();
        }
Ejemplo n.º 7
0
 public void Stop()
 {
     PlaybackDevice?.Stop();
     if (FileStream != null)
     {
         FileStream.Position = 0;
     }
 }
Ejemplo n.º 8
0
 public void PlaySoundTo(PlaybackDevice Device)
 {
     if (Connectedb)
     {
         StartPlayingToSounddevice_Client(Device);
     }
     else
     {
         throw new NotConnectedException(this, "The call has not been connected yet!");
     }
 }
 public static IAudioDevice ToAudioDevice(this PlaybackDevice playbackDevice)
 {
     return(new PlaybackAudioDevice
     {
         Id = $"{AudioDevices.Output}-{playbackDevice.DeviceIndex}",
         Name = playbackDevice.DeviceInfo.Name,
         Type = AudioDevices.Output,
         DeviceInfo = playbackDevice.DeviceInfo,
         PlaybackDevice = playbackDevice
     });
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Called when the PlaybackDeviceAvailableMessage message is received
        /// If this is a change then report it
        /// </summary>
        /// <param name="message"></param>
        private static void DeviceAvailable(PlaybackDevice newDevice)
        {
            // If the view data is not available yet, just update the model.
            // Otherwise report to the view and then update the model
            MediaControllerViewModel.PlaybackDeviceAvailable = (newDevice != null);

            if (dataReporter.DataAvailable == true)
            {
                DataReporter?.DeviceAvailable();
            }
        }
Ejemplo n.º 11
0
 private void SetupFilePipeline(String fileName)
 {
     pipeline = new Pipeline();
     using (var cfg = FromFile(new Config(), fileName))
         using (var pp = pipeline.Start(cfg))
             using (var dev = pp.Device)
                 using (playback = PlaybackDevice.FromDevice(dev))
                 {
                     Console.WriteLine("Reading from : " + playback.FileName);
                     playback.Realtime = false;
                 }
 }
Ejemplo n.º 12
0
 private void OpenFile(string fileName, int fftLength)
 {
     try
     {
         var inputStream = new AudioFileReader(fileName);
         FileStream = inputStream;
         var aggregator = new STFTSampleProvider(inputStream, ShortTimeFourierTransform, fftLength);
         PlaybackDevice.Init(aggregator);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         CloseFile();
     }
 }
Ejemplo n.º 13
0
        static void runFromFile(String fileName)
        {
            using (var pipe = new Pipeline())
                using (var cfg = FromFile(new Config(), fileName))
                    using (var pp = pipe.Start(cfg))
                        using (var dev = pp.Device)
                            using (var playback = PlaybackDevice.FromDevice(dev))
                            {
                                Console.WriteLine("Reading from : " + playback.FileName);
                                playback.Realtime = false;

                                while (playback.Status != PlaybackStatus.Stopped)
                                {
                                    runCycle(pipe);
                                }
                            }
        }
        /// <summary>
        /// Called when a new remote media device has been detected
        /// </summary>
        /// <param name="device"></param>
        private static void NewDeviceDetected(PlaybackDevice device)
        {
            // Add this device to the model if it supports playback
            if ((device.CanPlayMedia == PlaybackDevice.CanPlayMediaType.Yes) && (PlaybackSelectionModel.RemoteDevices.AddDevice(device) == true))
            {
                // If this device is the currently selected device then report it as available
                if (device.FriendlyName == PlaybackSelectionModel.SelectedDeviceName)
                {
                    PlaybackSelectionModel.SelectedDevice = device;
                    new PlaybackDeviceAvailableMessage()
                    {
                        SelectedDevice = device
                    }.Send();
                }

                // Report that the Playback Selection model have changed
                new PlaybackModelChangedMessage().Send();
            }
        }
        /// <summary>
        /// Called when the user has selected a new playback device
        /// Save it in the model and report it
        /// </summary>
        /// <param name="deviceName"></param>
        public static void SetSelectedPlayback(string deviceName)
        {
            PlaybackDevice selectedDevice = PlaybackSelectionModel.RemoteDevices.FindDevice(deviceName);

            if (selectedDevice != null)
            {
                PlaybackSelectionModel.SelectedDevice     = selectedDevice;
                PlaybackSelectionModel.SelectedDeviceName = selectedDevice.FriendlyName;
                Playback.PlaybackDeviceName = PlaybackSelectionModel.SelectedDeviceName;

                new PlaybackDeviceAvailableMessage()
                {
                    SelectedDevice = PlaybackSelectionModel.SelectedDevice
                }.Send();

                // Report that the Playback Selection model have changed
                new PlaybackModelChangedMessage().Send();
            }
        }
        /// <summary>
        /// Called when a previously available device is no longer available
        /// </summary>
        /// <param name="device"></param>
        private static void DeviceNotAvailable(PlaybackDevice device)
        {
            // Remove this device from the model
            if (PlaybackSelectionModel.RemoteDevices.RemoveDevice(device) == true)
            {
                // If this device is currently selected then report that there is no selected device
                if (PlaybackSelectionModel.SelectedDevice == device)
                {
                    PlaybackSelectionModel.SelectedDevice = null;
                    new PlaybackDeviceAvailableMessage()
                    {
                        SelectedDevice = null
                    }.Send();
                }

                // Report that the Playback Selection model have changed
                new PlaybackModelChangedMessage().Send();
            }
        }
Ejemplo n.º 17
0
        public static Pipeline FromFile(string filename)
        {
            if (!File.Exists(filename))
            {
                Console.WriteLine("Error: file {0} does not exists.", filename); return(null);
            }

            Pipeline        pipeline = new Pipeline();
            Config          config   = ConfigFile(new Config(), filename);
            PipelineProfile profile  = pipeline.Start(config);

            Device         device   = profile.Device;
            PlaybackDevice playback = PlaybackDevice.FromDevice(device);

            DateTime begins = DateTime.Now;

            Console.WriteLine("Reading file {0}\nDuration time: {1}\nCamera name: {2}\nSerial number: {3}\nFirmware version: {4}\n", filename, TimeSpan.FromMilliseconds(playback.Duration * 1e-6), device.Info[CameraInfo.Name], device.Info[CameraInfo.SerialNumber], device.Info[CameraInfo.FirmwareVersion]);
            playback.Realtime = false;

            return(pipeline);
        }
Ejemplo n.º 18
0
 public void Pause()
 {
     PlaybackDevice?.Pause();
 }
    // string[] names = { };
    // string[] serials;
    // int selectedSerial = 0;


    // private void PopuplateDevices()
    // {
    //     using (var ctx = new Context())
    //     using (var device_list = ctx.QueryDevices())
    //     {
    //         serials = device_list.Select(d => d.Info[CameraInfo.SerialNumber]).ToArray();
    //         var _names = device_list.Select(d => d.Info[CameraInfo.Name]);
    //         var m = _names.Max(d => d.Length);
    //         names = _names.Select((n, i) => string.Format("{0}    SN: {1}", n.PadRight(m), serials[i])).ToArray();
    //     }
    // }

    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        // EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"), true);

        var device = target as RsDevice;
        // bool isStreaming = device.ActiveProfile != null;
        bool isStreaming = device.isActiveAndEnabled && device.ActiveProfile != null;

        EditorGUI.BeginChangeCheck();

        EditorGUILayout.Space();
        EditorGUI.BeginDisabledGroup(isStreaming);
        mode.enumValueIndex = GUILayout.Toolbar(mode.enumValueIndex, mode.enumDisplayNames);

        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("processMode"));
        EditorGUILayout.Space();
        EditorGUI.EndDisabledGroup();


        // EditorGUILayout.PropertyField(serializedObject.FindProperty("DeviceConfiguration"), true);

        switch ((RsConfiguration.Mode)mode.enumValueIndex)
        {
        case RsConfiguration.Mode.Live:
            // EditorGUILayout.BeginHorizontal();
            // var sn = config.FindPropertyRelative("RequestedSerialNumber");
            // selectedSerial = EditorGUILayout.Popup(selectedSerial, names);
            // if (serials != null && serials.Length != 0)
            //     sn.stringValue = serials[selectedSerial];

            // if (GUILayout.Button("Update", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
            // {
            //     PopuplateDevices();
            // }
            // EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(isStreaming);
            EditorGUILayout.PropertyField(config.FindPropertyRelative("RequestedSerialNumber"));

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(config.FindPropertyRelative("Profiles"), true);
            // EditorGUILayout.Space();
            // EditorGUILayout.PropertyField(serializedObject.FindProperty("_processingPipe"), false);
            EditorGUILayout.Space();
            EditorGUI.EndDisabledGroup();
            break;

        case RsConfiguration.Mode.Playback:
        {
            EditorGUI.BeginDisabledGroup(isStreaming);
            EditorGUILayout.BeginHorizontal();
            var prop = config.FindPropertyRelative("PlaybackFile");
            EditorGUILayout.PropertyField(prop);
            if (GUILayout.Button("Open", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
            {
                var path = EditorUtility.OpenFilePanel("Recorded sequence", "", "bag");
                if (path.Length != 0)
                {
                    prop.stringValue = path;
                }
            }
            EditorGUILayout.EndHorizontal();
            // EditorGUILayout.Space();
            // EditorGUILayout.PropertyField(serializedObject.FindProperty("_processingPipe"), false);
            EditorGUILayout.Space();
            EditorGUI.EndDisabledGroup();

            if (isStreaming)
            {
                using (var playback = PlaybackDevice.FromDevice(device.ActiveProfile.Device))
                {
                    bool isPlaying = playback.Status == PlaybackStatus.Playing;

                    //TODO: cache icons (in OnEnable)
                    var playBtnStyle = EditorGUIUtility.IconContent("PlayButton", "|Play");
                    // var playBtnStyle = EditorGUIUtility.IconContent("Animation.Play");

                    var pauseBtnStyle = EditorGUIUtility.IconContent("PauseButton", "|Pause");

                    // var stepBtnStyle = EditorGUIUtility.IconContent("StepButton", "|Step");

                    // var rewindBtnStyle = EditorGUIUtility.IconContent("Animation.PrevKey");
                    var rewindBtnStyle = EditorGUIUtility.IconContent("animation.firstkey.png");

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(rewindBtnStyle, "CommandLeft"))
                    {
                        playback.Position = 0;
                    }

                    if (GUILayout.Button(isPlaying ? pauseBtnStyle : playBtnStyle, "CommandRight"))
                    {
                        if (isPlaying)
                        {
                            playback.Pause();
                        }
                        else
                        {
                            playback.Resume();
                        }
                    }

                    // bool play = GUILayout.Toggle(isPlaying, playBtnStyle, "CommandMid");
                    // if (play && !isPlaying)
                    //     playback.Resume();

                    // bool pause = GUILayout.Toggle(!isPlaying, pauseBtnStyle, "CommandRight");
                    // if (pause && isPlaying)
                    //     playback.Pause();

                    // if (GUILayout.Button(stepBtnStyle, "CommandRight"))
                    // {
                    // }

                    //TODO: no getter...
                    // playback.Speed = EditorGUILayout.FloatField(playback.Speed);

                    GUILayout.EndHorizontal();

                    if (!isPlaying)
                    {
                        // var t = TimeSpan.FromMilliseconds(playback.Position * 1e-6);
                        // playback.Position = (ulong)EditorGUILayout.Slider(t.ToString(), playback.Position, 0, playback.Duration);
                        playback.Position = (ulong)EditorGUILayout.Slider(playback.Position, 0, playback.Duration);
                    }


                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(config.FindPropertyRelative("Profiles"), true);
                    EditorGUI.EndDisabledGroup();
                }
            }
        }
        break;

        case RsConfiguration.Mode.Record:
        {
            EditorGUILayout.BeginHorizontal();
            var prop = config.FindPropertyRelative("RecordPath");
            EditorGUILayout.PropertyField(prop);
            if (GUILayout.Button("Choose", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
            {
                var path = EditorUtility.SaveFilePanel("Recorded sequence", "", System.DateTime.Now.ToString("yyyyMMdd_hhmmss"), "bag");
                if (path.Length != 0)
                {
                    prop.stringValue = path;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(config.FindPropertyRelative("Profiles"), true);
            // EditorGUILayout.Space();
            // EditorGUILayout.PropertyField(serializedObject.FindProperty("_processingPipe"), false);
            EditorGUILayout.Space();
            EditorGUI.EndDisabledGroup();
        }
        break;
        }


        serializedObject.ApplyModifiedProperties();

        EditorGUI.EndChangeCheck();
    }
Ejemplo n.º 20
0
        protected void Dispose(bool disposing)
        {
            if (this.isDisposed)
                return;

            OpenAL.DebugFormat ("Freeing OpenALPlaybackProvider. Disposing: ", disposing);

            if (disposing)
            {
                this.pool.Dispose();

                if (this.device != null)
                    this.device.Dispose();
            }

            SourceBuffer.Clear();

            OpenALRunner.RemoveUser();
            OpenALRunner.RemovePlaybackProvider (this);
            this.pool = null;
            this.device = null;
            this.isDisposed = true;
        }
 /// <summary>
 /// Called when a new DLNA device has been detected
 /// </summary>
 /// <param name="device"></param>
 public void NewDeviceDetected(PlaybackDevice device) => PlaybackSelectionController.NewDeviceDetected(device);
Ejemplo n.º 22
0
 /// <summary>
 /// Called when a new DLNA device has been detected
 /// </summary>
 /// <param name="device"></param>
 public void NewDeviceDetected(PlaybackDevice device) => BasePlayback.NewDeviceDetected(device);
Ejemplo n.º 23
0
 public override void Play(ISoundable sound)
 {
     Output.Write("Play sound in Mobile" + Environment.NewLine);
     PlaybackDevice.Play(sound);
 }