int video_play(int flags) { if (!gst_element_set_state(pipeline, GST_STATE_PAUSED)) return VIDEO_ERROR; /* Ugly hack: Must disable audio because the GStreamer 'speed' element * is broken in the 0.8.9 release. */ if (flags & VIDEO_SLOW_2X) { disable_audio(); g_object_set (G_OBJECT (vdrop), "speed", 0.5, NULL); } else if (flags & VIDEO_FAST_2X) { disable_audio(); g_object_set (G_OBJECT (vdrop), "speed", 2.0, NULL); } else if (flags & VIDEO_NORMAL_SPEED) { enable_audio(); g_object_set (G_OBJECT (vdrop), "speed", 1.0, NULL); } if (!gst_element_set_state(pipeline, GST_STATE_PLAYING)) return VIDEO_ERROR; return VIDEO_OK; }
safe_ptr<basic_frame> receive(int hints) { try { if(is_paused_) return disable_audio(foreground_->last_frame()); auto frame = receive_and_follow(foreground_, hints); if(frame == core::basic_frame::late()) return foreground_->last_frame(); auto frames_left = static_cast<int64_t>(foreground_->nb_frames()) - static_cast<int64_t>(++frame_number_) - static_cast<int64_t>(auto_play_delta_); if(auto_play_delta_ > -1 && frames_left < 1) { play(); return receive(hints); } return frame; } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); stop(); return core::basic_frame::empty(); } }
safe_ptr<basic_frame> receive() { try { if(is_paused_) return disable_audio(foreground_->last_frame()); auto frame = receive_and_follow(foreground_, frame_producer::NO_HINT); if(frame == core::basic_frame::late()) return foreground_->last_frame(); auto frames_left = foreground_->nb_frames() - (++frame_number_) - auto_play_delta_; if(auto_play_delta_ > -1 && frames_left < 1) { play(); return receive(); } return frame; } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); stop(); return core::basic_frame::empty(); } }
safe_ptr<basic_frame> receive(int hints) { try { monitor_subject_ << monitor::message("/paused") % is_paused_; if(is_paused_) { if(foreground_->last_frame() == basic_frame::empty()) foreground_->receive(frame_producer::NO_HINT); return disable_audio(foreground_->last_frame()); } auto foreground = foreground_; auto frame = receive_and_follow(foreground, hints); if(foreground != foreground_) set_foreground(foreground); if(frame == core::basic_frame::late()) return foreground_->last_frame(); auto frames_left = static_cast<int64_t>(foreground_->nb_frames()) - static_cast<int64_t>(++frame_number_) - static_cast<int64_t>(auto_play_delta_); if(auto_play_delta_ > -1 && frames_left < 1) { play(); return receive(hints); } return frame; } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); stop(); return core::basic_frame::empty(); } }
virtual safe_ptr<core::basic_frame> last_frame() const override { return disable_audio(last_frame_); }