void AdaptiveSrcManager_AdaptiveSourceStatusUpdatedEvent(AdaptiveSource sender, AdaptiveSourceStatusUpdatedEventArgs args) { lock (adaptiveSourceLock) { if (IsOpen && ActiveAdaptiveSource == args.AdaptiveSource) { switch (args.UpdateType) { case AdaptiveSourceStatusUpdateType.BitrateChanged: var videoStream = VideoStream; if (videoStream != null) { var bitrateInfo = args.AdditionalInfo.Split(';'); var bitrate = uint.Parse(bitrateInfo[0]); var timeStamp = long.Parse(bitrateInfo[1]); var selectedTrack = videoStream.SelectedTracks.FirstOrDefault(t => t.Bitrate == bitrate); if (selectedTrack != null) { lock (bitrateLog) // make this is thread safe since we'll be accessing it from the UI thread in .RefreshState { bitrateLog.Add(new BitrateLogEntry(timeStamp, selectedTrack)); } } } break; case AdaptiveSourceStatusUpdateType.EndOfLive: IsLive = false; RunOnProtectedUIThread(() => { if (EndOfLive != null) { EndOfLive(this, EventArgs.Empty); } }); break; case AdaptiveSourceStatusUpdateType.StartEndTime: StartTime = args.StartTime; EndTime = Math.Max(args.EndTime, args.StartTime + args.AdaptiveSource.Manifest.Duration); LivePosition = args.EndTime; RunOnProtectedUIThread(() => { if (TimesChanged != null) { TimesChanged(this, EventArgs.Empty); } }); break; case AdaptiveSourceStatusUpdateType.OutsideWindowEdge: RunOnProtectedUIThread(() => { if (OutsideWindowEdge != null) { OutsideWindowEdge(this, EventArgs.Empty); } }); break; } } } }
private void mediaElement_AdaptiveSourceStatusUpdated(AdaptiveSource sender, AdaptiveSourceStatusUpdatedEventArgs args) { adaptiveSourceStatusUpdate = args; }
void OnStatusUpdated(AdaptiveSourceStatusUpdatedEventArgs args) { switch (args.UpdateType) { case AdaptiveSourceStatusUpdateType.NextChunkHttpInvalid: case AdaptiveSourceStatusUpdateType.ChunkConnectHttpInvalid: if (ChunkFailure != null) { var failureEventArgs = new ChunkFailureEventArgs(); failureEventArgs.HttpResponse = args.HttpResponse; failureEventArgs.ChunkId = args.AdditionalInfo; ChunkFailure(this, failureEventArgs); } break; case AdaptiveSourceStatusUpdateType.BitrateChanged: var videoStream = VideoStream; if (videoStream != null) { var bitrateInfo = args.AdditionalInfo.Split(';'); var bitrate = uint.Parse(bitrateInfo[0]); var timeStamp = long.Parse(bitrateInfo[1]); var selectedTrack = videoStream.SelectedTracks.FirstOrDefault(t => t.Bitrate == bitrate); if (selectedTrack != null) { lock (bitrateLog) // make this is thread safe since we'll be accessing it from the UI thread in .RefreshState { bitrateLog.Add(new BitrateLogEntry(timeStamp, selectedTrack)); } } } break; case AdaptiveSourceStatusUpdateType.ChunkDownloaded: var addtionalInfo = args.AdditionalInfo.Split(';'); var chunkIndex = int.Parse(addtionalInfo[0]); var url = addtionalInfo[1]; var mediaStreamType = (Microsoft.Media.AdaptiveStreaming.MediaStreamType) int.Parse(addtionalInfo[2]); var chunkStartTimeHns = ulong.Parse(addtionalInfo[3]); var chunkDurationns = ulong.Parse(addtionalInfo[4]); var chunkBitrate = uint.Parse(addtionalInfo[5]); var chunkByteCount = uint.Parse(addtionalInfo[6]); var downloadRequestTimeMs = uint.Parse(addtionalInfo[7]); var downloadCompletedTimeMs = uint.Parse(addtionalInfo[8]); var chunkPerceivedBandwidth = uint.Parse(addtionalInfo[9]); var avgPerceivedBandwidth = uint.Parse(addtionalInfo[10]); var bufferLevelAtRequested90kHz = uint.Parse(addtionalInfo[11]); var bufferLevelAtCompleted90kHz = uint.Parse(addtionalInfo[12]); var responseHeaders = addtionalInfo[13]; // update properties PerceivedBandwidth = avgPerceivedBandwidth; switch (mediaStreamType) { case MediaStreamType.Audio: AudioBufferSize = bufferLevelAtCompleted90kHz; break; case MediaStreamType.Video: VideoBufferSize = bufferLevelAtCompleted90kHz; break; } if (ChunkDownloaded != null) // notify that a new chunk has downloaded { var chunkInfo = new ChunkDownloadedEventArgs(); chunkInfo.ChunkId = chunkIndex; chunkInfo.DownloadTimeMs = downloadCompletedTimeMs - downloadRequestTimeMs; chunkInfo.StartTime = chunkStartTimeHns; chunkInfo.StreamType = mediaStreamType.ToString().ToLowerInvariant(); chunkInfo.PerceivedBandwidth = chunkPerceivedBandwidth; chunkInfo.Bitrate = chunkBitrate; chunkInfo.ByteCount = chunkByteCount; ChunkDownloaded(this, chunkInfo); } break; } }
void adaptiveSourceManager_AdaptiveSourceStatusUpdatedEvent(AdaptiveSource sender, AdaptiveSourceStatusUpdatedEventArgs args) { //throw new NotImplementedException(); try { //Schedules the provided callback on the UI thread from a worker thread, and returns the results asynchronously. this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { //log(" AdaptiveSource Opened: " + "URI: " + displayedUri); // log(args.UpdateType + " " + additionalInfo); //removed args.startTime() and args.EndTime() // log(stopWatch.Elapsed + " " + args.UpdateType + args.AdditionalInfo + "\n"); log("Time: " + stopWatch.Elapsed + " " + args.UpdateType + " " + args.AdditionalInfo + "\n\n"); }); } catch (Exception ex) { //Schedules the provided callback on the UI thread from a worker thread, and returns the results asynchronously. this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { log("error" + ex.Message.ToString()); }); } }//End of MainPage()
void source_AdaptiveSourceStatusUpdatedEvent(AdaptiveSource sender, AdaptiveSourceStatusUpdatedEventArgs args) { OnStatusUpdated(args); }