/// <summary> /// Initialize AV frame player. /// </summary> /// <returns>Task denoting creation of the player with initial frames enqueued.</returns> private async Task StartAudioVideoFramePlayerAsync() { try { await Task.WhenAll(this.audioSendStatusActive.Task, this.videoSendStatusActive.Task).ConfigureAwait(false); this.logger.Info("Send status active for audio and video Creating the audio video player"); this.audioVideoFramePlayerSettings = new AudioVideoFramePlayerSettings(new AudioSettings(20), new VideoSettings(), 1000); this.audioVideoFramePlayer = new AudioVideoFramePlayer( (AudioSocket)this.audioSocket, (VideoSocket)this.mainVideoSocket, this.audioVideoFramePlayerSettings); this.logger.Info("created the audio video player"); this.audioVideoFramePlayer.LowOnFrames += this.OnAudioVideoFramePlayerLowOnFrames; // Create AV buffers var currentTick = DateTime.Now.Ticks; this.CreateAVBuffers(currentTick, replayed: false); await this.audioVideoFramePlayer.EnqueueBuffersAsync(this.audioMediaBuffers, this.videoMediaBuffers).ConfigureAwait(false); } catch (Exception ex) { this.logger.Error(ex, "Failed to create the audioVideoFramePlayer with exception"); } finally { this.startVideoPlayerCompleted.TrySetResult(true); } }
private async Task StartTTS() { // wait for the audio channel to be active await Task.WhenAll(_audioSendStatusActive.Task); // create an audio/video frame player with audio channel only AudioVideoFramePlayer audioVideoFramePlayer = new AudioVideoFramePlayer(_audioSocket, null, new AudioVideoFramePlayerSettings(new AudioSettings(20), new VideoSettings(), 1000)); // list of AudioMediaBuffer to be sent to the player... we will populate this buffers with the audio coming from the two TTS engines var audioMediaBuffers = new List <AudioMediaBuffer>(); // reference time tick for the audio buffers var referenceTimeTicks = DateTime.Now.Ticks; String text = "I'm completely operational, and all my circuits are functioning perfectly."; // create the local TTS engine ITtsEngine localTts = new TtsEngineLocal(); referenceTimeTicks = populateAudioBuffersFromStream(localTts.SynthesizeText(text), audioMediaBuffers, referenceTimeTicks); // create the TTS service engine ITtsEngine serviceTts = new TtsEngineService(); populateAudioBuffersFromStream(serviceTts.SynthesizeText(text), audioMediaBuffers, referenceTimeTicks); // enqueue the audio buffers, passing an empty list of video buffers since our player is audio only await audioVideoFramePlayer.EnqueueBuffersAsync(audioMediaBuffers, new List <VideoMediaBuffer>()); }
private async Task StartAudioVideoFramePlayer() { try { await Task.WhenAll(_audioSendStatusActive.Task, _videoSendStatusActive.Task); Log.Info( new CallerInfo(), LogContext.Media, "Send status active for audio and video Creating the audio video player"); AudioVideoFramePlayerSettings settings = new AudioVideoFramePlayerSettings(new AudioSettings(20), new VideoSettings(), _mediaBufferToLoadInSeconds * 1000); _audioVideoFramePlayer = new AudioVideoFramePlayer(_audioSocket, _videoSocket, settings); Log.Info( new CallerInfo(), LogContext.Media, "created the audio video player"); _downloadManager.ConnectToStorageAccount(); _audioVideoFramePlayer.LowOnFrames += OnLowOnFrames; var currentTick = DateTime.Now.Ticks; _videoMediaBuffers = _downloadManager.GetVideoMediaBuffers(currentTick); _audioMediaBuffers = _downloadManager.GetAudioMediaBuffers(currentTick); //update the tick for next iteration _mediaTick = Math.Max(_audioMediaBuffers.Last().Timestamp, _videoMediaBuffers.Last().Timestamp); await _audioVideoFramePlayer.EnqueueBuffersAsync(_audioMediaBuffers, _videoMediaBuffers); } finally { _startVideoPlayerCompleted.Set(); } }
/// <summary> /// Creates the vbss player that will stream the video buffers for the sharer. /// </summary> private void CreateVbssFramePlayer() { try { this.logger.Info("Creating the vbss FramePlayer"); this.audioVideoFramePlayerSettings = new AudioVideoFramePlayerSettings(new AudioSettings(20), new VideoSettings(), 1000); this.vbssFramePlayer = new AudioVideoFramePlayer( null, (VideoSocket)this.vbssSocket, this.audioVideoFramePlayerSettings); this.vbssFramePlayer.LowOnFrames += this.OnVbssPlayerLowOnFrames; } catch (Exception ex) { this.logger.Error(ex, $"Failed to create the vbssFramePlayer with exception {ex}"); } }
private async Task StartTTVS() { // wait for both the audio and video channels to be active await Task.WhenAll(_audioSendStatusActive.Task, _videoSendStatusActive.Task); // create an audio/video frame player audioVideoFramePlayer = new AudioVideoFramePlayer(_audioSocket, _videoSocket, new AudioVideoFramePlayerSettings(new AudioSettings(20), new VideoSettings(), 1000)); // lists of buffers to be sent to the player... we will populate this buffers with the audio/video coming from the TTVS engines var audioMediaBuffers = new List <AudioMediaBuffer>(); var videoMediaBuffers = new List <VideoMediaBuffer>(); // create the TTVS engine and generate the media buffers TtvsEngine ttvsEngine = new TtvsEngine(_defaultVideoFormat); string welcomeText = "I'm completely operational, and all my circuits are functioning perfectly!"; ttvsEngine.SynthesizeText(welcomeText, audioMediaBuffers, videoMediaBuffers); await audioVideoFramePlayer.EnqueueBuffersAsync(audioMediaBuffers, videoMediaBuffers); }