X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=quicksync_encoder.cpp;h=41ace54263d1d235e8a02c4a905ac9fc34e8f3c0;hb=3f34da3ebb9a6fd1ed267f9186d17433321a9214;hp=7d211798a504d07e91137e77a77815732ebad3a1;hpb=f6ba0b7586dfbdbee665a541ae5f5297063fedcc;p=nageru diff --git a/quicksync_encoder.cpp b/quicksync_encoder.cpp index 7d21179..41ace54 100644 --- a/quicksync_encoder.cpp +++ b/quicksync_encoder.cpp @@ -193,7 +193,7 @@ FrameReorderer::Frame FrameReorderer::get_first_frame() class QuickSyncEncoderImpl { public: - QuickSyncEncoderImpl(const std::string &filename, QSurface *surface, const string &va_display, int width, int height, Mux *stream_mux, AudioEncoder *stream_audio_encoder); + QuickSyncEncoderImpl(const std::string &filename, QSurface *surface, const string &va_display, int width, int height, Mux *stream_mux, AudioEncoder *stream_audio_encoder, X264Encoder *x264_encoder); ~QuickSyncEncoderImpl(); void add_audio(int64_t pts, vector audio); bool begin_frame(GLuint *y_tex, GLuint *cbcr_tex); @@ -275,12 +275,12 @@ private: unique_ptr file_audio_encoder; AudioEncoder *stream_audio_encoder; + unique_ptr reorderer; + X264Encoder *x264_encoder; // nullptr if not using x264. + Mux* stream_mux; // To HTTP. unique_ptr file_mux; // To local disk. - unique_ptr reorderer; - unique_ptr x264_encoder; // nullptr if not using x264. - Display *x11_display = nullptr; // Encoder parameters @@ -1730,8 +1730,8 @@ namespace { } // namespace -QuickSyncEncoderImpl::QuickSyncEncoderImpl(const std::string &filename, QSurface *surface, const string &va_display, int width, int height, Mux *stream_mux, AudioEncoder *stream_audio_encoder) - : current_storage_frame(0), surface(surface), stream_audio_encoder(stream_audio_encoder), stream_mux(stream_mux), frame_width(width), frame_height(height) +QuickSyncEncoderImpl::QuickSyncEncoderImpl(const std::string &filename, QSurface *surface, const string &va_display, int width, int height, Mux *stream_mux, AudioEncoder *stream_audio_encoder, X264Encoder *x264_encoder) + : current_storage_frame(0), surface(surface), stream_audio_encoder(stream_audio_encoder), x264_encoder(x264_encoder), stream_mux(stream_mux), frame_width(width), frame_height(height) { file_audio_encoder.reset(new AudioEncoder(AUDIO_OUTPUT_CODEC_NAME, DEFAULT_AUDIO_OUTPUT_BIT_RATE)); open_output_file(filename); @@ -1747,7 +1747,9 @@ QuickSyncEncoderImpl::QuickSyncEncoderImpl(const std::string &filename, QSurface reorderer.reset(new FrameReorderer(ip_period - 1, frame_width, frame_height)); } if (global_flags.x264_video_to_http) { - x264_encoder.reset(new X264Encoder(stream_mux)); + assert(x264_encoder != nullptr); + } else { + assert(x264_encoder == nullptr); } init_va(va_display); @@ -1919,7 +1921,6 @@ void QuickSyncEncoderImpl::shutdown() frame_queue_nonempty.notify_all(); } encode_thread.join(); - x264_encoder.reset(); { unique_lock lock(storage_task_queue_mutex); storage_thread_should_quit = true; @@ -2171,8 +2172,8 @@ void QuickSyncEncoderImpl::encode_frame(QuickSyncEncoderImpl::PendingFrame frame } // Proxy object. -QuickSyncEncoder::QuickSyncEncoder(const std::string &filename, QSurface *surface, const string &va_display, int width, int height, Mux *stream_mux, AudioEncoder *stream_audio_encoder) - : impl(new QuickSyncEncoderImpl(filename, surface, va_display, width, height, stream_mux, stream_audio_encoder)) {} +QuickSyncEncoder::QuickSyncEncoder(const std::string &filename, QSurface *surface, const string &va_display, int width, int height, Mux *stream_mux, AudioEncoder *stream_audio_encoder, X264Encoder *x264_encoder) + : impl(new QuickSyncEncoderImpl(filename, surface, va_display, width, height, stream_mux, stream_audio_encoder, x264_encoder)) {} // Must be defined here because unique_ptr<> destructor needs to know the impl. QuickSyncEncoder::~QuickSyncEncoder() {}