protected void Cleanup() { m_CurrentServer = null; // free the buffers if (m_IngestBuffers != null) { for (int i = 0; i < m_IngestBuffers.Count; ++i) { m_Stream.FreeFrameBuffer(m_IngestBuffers[i]); } m_IngestBuffers = null; } if (m_Stream.StatsListener == m_StatCallbackListener) { m_Stream.StatsListener = m_PreviousStatCallbacks; m_PreviousStatCallbacks = null; } if (m_Stream.BroadcastApiListener == m_StreamCallbackListener) { m_Stream.BroadcastApiListener = m_PreviousStreamCallbacks; m_PreviousStreamCallbacks = null; } }
protected void Cleanup() { m_CurrentServer = null; // free the buffers if (m_IngestBuffers != null) { for (int i = 0; i < m_IngestBuffers.Count; ++i) { m_Stream.FreeFrameBuffer(m_IngestBuffers[i]); } m_IngestBuffers = null; } if (m_Stream.StatsListener == m_StatCallbackListener) { m_Stream.StatsListener = m_PreviousStatCallbacks; m_PreviousStatCallbacks = null; } if (m_Stream.BroadcastApiListener == m_StreamCallbackListener) { m_Stream.BroadcastApiListener = m_PreviousStreamCallbacks; m_PreviousStreamCallbacks = null; } }
/// <summary> /// Begins the ingest testing. /// </summary> public void Start() { // can only run it once per instance if (m_TestState != TestState.Uninitalized) { return; } m_StreamCallbackListener = new StreamCallbackListener(this); m_StatCallbackListener = new StatCallbackListener(this); m_CurrentServerIndex = 0; m_CancelTest = false; m_SkipServer = false; m_Broadcasting = false; m_WaitingForStartCallback = false; m_WaitingForStopCallback = false; m_PreviousStatCallbacks = m_Stream.StatsListener; m_Stream.StatsListener = m_StatCallbackListener; m_PreviousStreamCallbacks = m_Stream.BroadcastApiListener; m_Stream.BroadcastApiListener = m_StreamCallbackListener; m_IngestTestVideoParams = new VideoParams(); m_IngestTestVideoParams.TargetFps = Twitch.Broadcast.Constants.TTV_MAX_FPS; m_IngestTestVideoParams.MaxKbps = Twitch.Broadcast.Constants.TTV_MAX_BITRATE; m_IngestTestVideoParams.OutputWidth = 1280; m_IngestTestVideoParams.OutputHeight = 720; m_IngestTestVideoParams.PixelFormat = PixelFormat.TTV_PF_BGRA; m_IngestTestVideoParams.DisableAdaptiveBitrate = true; m_IngestTestVideoParams.VerticalFlip = false; m_Stream.GetDefaultParams(m_IngestTestVideoParams); m_IngestTestAudioParams = new AudioParams(); m_IngestTestAudioParams.AudioEnabled = false; m_IngestTestAudioParams.EnableMicCapture = false; m_IngestTestAudioParams.EnablePlaybackCapture = false; m_IngestTestAudioParams.EnablePassthroughAudio = false; m_IngestBuffers = new List <UIntPtr>(); // allocate some buffers int numFrames = 3; for (int i = 0; i < numFrames; ++i) { UIntPtr buffer = UIntPtr.Zero; uint size = m_IngestTestVideoParams.OutputWidth * m_IngestTestVideoParams.OutputHeight * 4; m_Stream.AllocateFrameBuffer(size, out buffer); if (buffer == UIntPtr.Zero) { Cleanup(); SetTestState(TestState.Failed); return; } m_Stream.RandomizeFrameBuffer(buffer, size); m_IngestBuffers.Add(buffer); } SetTestState(TestState.Starting); m_Timer.Reset(); m_Timer.Start(); }
/// <summary> /// Begins the ingest testing. /// </summary> public void Start() { // can only run it once per instance if (m_TestState != TestState.Uninitalized) { return; } m_StreamCallbackListener = new StreamCallbackListener(this); m_StatCallbackListener = new StatCallbackListener(this); m_CurrentServerIndex = 0; m_CancelTest = false; m_SkipServer = false; m_Broadcasting = false; m_WaitingForStartCallback = false; m_WaitingForStopCallback = false; m_PreviousStatCallbacks = m_Stream.StatsListener; m_Stream.StatsListener = m_StatCallbackListener; m_PreviousStreamCallbacks = m_Stream.BroadcastApiListener; m_Stream.BroadcastApiListener = m_StreamCallbackListener; m_IngestTestVideoParams = new VideoParams(); m_IngestTestVideoParams.TargetFps = Twitch.Broadcast.Constants.TTV_MAX_FPS; m_IngestTestVideoParams.MaxKbps = Twitch.Broadcast.Constants.TTV_MAX_BITRATE; m_IngestTestVideoParams.OutputWidth = 1280; m_IngestTestVideoParams.OutputHeight = 720; m_IngestTestVideoParams.PixelFormat = PixelFormat.TTV_PF_BGRA; m_IngestTestVideoParams.DisableAdaptiveBitrate = true; m_IngestTestVideoParams.VerticalFlip = false; m_Stream.GetDefaultParams(m_IngestTestVideoParams); m_IngestTestAudioParams = new AudioParams(); m_IngestTestAudioParams.AudioEnabled = false; m_IngestTestAudioParams.EnableMicCapture = false; m_IngestTestAudioParams.EnablePlaybackCapture = false; m_IngestTestAudioParams.EnablePassthroughAudio = false; m_IngestBuffers = new List<UIntPtr>(); // allocate some buffers int numFrames = 3; for (int i = 0; i < numFrames; ++i) { UIntPtr buffer = UIntPtr.Zero; uint size = m_IngestTestVideoParams.OutputWidth * m_IngestTestVideoParams.OutputHeight * 4; m_Stream.AllocateFrameBuffer(size, out buffer); if (buffer == UIntPtr.Zero) { Cleanup(); SetTestState(TestState.Failed); return; } m_Stream.RandomizeFrameBuffer(buffer, size); m_IngestBuffers.Add(buffer); } SetTestState(TestState.Starting); m_Timer.Reset(); m_Timer.Start(); }