CameraBinImageCapture::CameraBinImageCapture(CameraBinSession *session) :QCameraImageCaptureControl(session) , m_session(session) , m_ready(false) , m_requestId(0) , m_jpegEncoderElement(0) , m_metadataMuxerElement(0) { connect(m_session, SIGNAL(stateChanged(QCamera::State)), SLOT(updateState())); connect(m_session, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed(int))); connect(m_session, SIGNAL(imageCaptured(int,QImage)), this, SIGNAL(imageCaptured(int,QImage))); connect(m_session, SIGNAL(busMessage(QGstreamerMessage)), SLOT(handleBusMessage(QGstreamerMessage))); g_signal_connect(G_OBJECT(m_session->cameraBin()), IMAGE_DONE_SIGNAL, G_CALLBACK(handleImageSaved), this); }
QGstreamerCaptureSession::QGstreamerCaptureSession(QGstreamerCaptureSession::CaptureMode captureMode, QObject *parent) :QObject(parent), m_state(StoppedState), m_pendingState(StoppedState), m_waitingForEos(false), m_pipelineMode(EmptyPipeline), m_captureMode(captureMode), m_audioInputFactory(0), m_audioPreviewFactory(0), m_videoInputFactory(0), m_viewfinder(0), m_viewfinderInterface(0), m_audioSrc(0), m_audioTee(0), m_audioPreviewQueue(0), m_audioPreview(0), m_audioVolume(0), m_muted(false), m_videoSrc(0), m_videoTee(0), m_videoPreviewQueue(0), m_videoPreview(0), m_imageCaptureBin(0), m_encodeBin(0), m_passImage(false), m_passPrerollImage(false) { m_pipeline = gst_pipeline_new("media-capture-pipeline"); gstRef(m_pipeline); m_bus = gst_element_get_bus(m_pipeline); m_busHelper = new QGstreamerBusHelper(m_bus, this); m_busHelper->installSyncEventFilter(this); connect(m_busHelper, SIGNAL(message(QGstreamerMessage)), SLOT(busMessage(QGstreamerMessage))); m_audioEncodeControl = new QGstreamerAudioEncode(this); m_videoEncodeControl = new QGstreamerVideoEncode(this); m_imageEncodeControl = new QGstreamerImageEncode(this); m_recorderControl = new QGstreamerRecorderControl(this); m_mediaContainerControl = new QGstreamerMediaContainerControl(this); setState(StoppedState); }
void PlaybinSession::readySession() { d->playbin = gst_element_factory_make("playbin", NULL); if (d->playbin != 0) { // Pre-set video element, even if no video d->sinkWidget = new DirectPainterWidget; g_object_set(G_OBJECT(d->playbin), "video-sink", d->sinkWidget->element(), NULL); // Sort out messages d->bus = gst_element_get_bus(d->playbin); d->busHelper = new BusHelper(d->bus, this); connect(d->busHelper, SIGNAL(message(Message)), SLOT(busMessage(Message))); // Initial volume g_object_get(G_OBJECT(d->playbin), "volume", &d->volume, NULL); // URI for media g_object_set(G_OBJECT(d->playbin), "uri", d->url.toString().toLocal8Bit().constData(), NULL); } }
void PlaybinSession::readySession() { d->playbin = gst_element_factory_make("playbin", NULL); if (d->playbin != 0) { // Pre-set video element, even if no video d->sinkWidget = new VideoWidget; connect( d->sinkWidget->videoSurface(), SIGNAL(formatsChanged()), this, SLOT(updateSinkFormat()) ); connect( d->sinkWidget->videoSurface(), SIGNAL(updateRequested()), this, SLOT(repaintLastFrame()) ); g_object_set(G_OBJECT(d->playbin), "video-sink", d->sinkWidget->element(), NULL); // Sort out messages d->bus = gst_element_get_bus(d->playbin); d->busHelper = new BusHelper(d->bus, this); connect(d->busHelper, SIGNAL(message(Message)), SLOT(busMessage(Message))); // Initial volume g_object_get(G_OBJECT(d->playbin), "volume", &d->volume, NULL); // URI for media g_object_set(G_OBJECT(d->playbin), "uri", d->url.toString().toLocal8Bit().constData(), NULL); } }
QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent) :QObject(parent), m_state(QMediaPlayer::StoppedState), m_pendingState(QMediaPlayer::StoppedState), m_busHelper(0), m_playbin(0), m_usePlaybin2(false), m_videoSink(0), m_pendingVideoSink(0), m_nullVideoSink(0), m_bus(0), m_videoOutput(0), m_renderer(0), m_volume(100), m_playbackRate(1.0), m_muted(false), m_audioAvailable(false), m_videoAvailable(false), m_seekable(false), m_lastPosition(0), m_duration(-1) { #ifdef USE_PLAYBIN2 m_playbin = gst_element_factory_make("playbin2", NULL); #endif if (m_playbin) { m_usePlaybin2 = true; //GST_PLAY_FLAG_NATIVE_VIDEO omits configuration of ffmpegcolorspace and videoscale, //since those elements are included in the video output bin. int flags = 0; g_object_get(G_OBJECT(m_playbin), "flags", &flags, NULL); flags |= GST_PLAY_FLAG_NATIVE_VIDEO; g_object_set(G_OBJECT(m_playbin), "flags", flags, NULL); } else { m_usePlaybin2 = false; m_playbin = gst_element_factory_make("playbin", NULL); } m_videoOutputBin = gst_bin_new("video-output-bin"); gst_object_ref(GST_OBJECT(m_videoOutputBin)); m_videoIdentity = gst_element_factory_make("identity", "identity-vo"); m_nullVideoSink = gst_element_factory_make("fakesink", NULL); gst_object_ref(GST_OBJECT(m_nullVideoSink)); gst_bin_add_many(GST_BIN(m_videoOutputBin), m_videoIdentity, m_nullVideoSink, NULL); gst_element_link_many(m_videoIdentity, m_nullVideoSink, NULL); //add an event probe before video output to save and repost segment events { gst_segment_init (&m_segment, GST_FORMAT_TIME); GstPad *srcPad = gst_element_get_static_pad(m_videoIdentity, "src"); gst_pad_add_event_probe(srcPad, G_CALLBACK(new_segment_probe), this); gst_pad_add_buffer_probe(srcPad, G_CALLBACK(new_buffer_probe), this); gst_object_unref(GST_OBJECT(srcPad)); } m_videoSink = m_nullVideoSink; // add ghostpads GstPad *pad = gst_element_get_static_pad(m_videoIdentity,"sink"); gst_element_add_pad(GST_ELEMENT(m_videoOutputBin), gst_ghost_pad_new("videosink", pad)); gst_object_unref(GST_OBJECT(pad)); if (m_playbin != 0) { // Sort out messages m_bus = gst_element_get_bus(m_playbin); m_busHelper = new QGstreamerBusHelper(m_bus, this); connect(m_busHelper, SIGNAL(message(QGstreamerMessage)), SLOT(busMessage(QGstreamerMessage))); m_busHelper->installSyncEventFilter(this); g_object_set(G_OBJECT(m_playbin), "video-sink", m_videoOutputBin, NULL); g_signal_connect(G_OBJECT(m_playbin), "notify::source", G_CALLBACK(playbinNotifySource), this); // Initial volume double volume = 1.0; g_object_get(G_OBJECT(m_playbin), "volume", &volume, NULL); m_volume = int(volume*100); } }
QT_BEGIN_NAMESPACE QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent) :QObject(parent), m_state(QMediaPlayer::StoppedState), m_busHelper(0), m_playbin(0), m_videoSink(0), m_pendingVideoSink(0), m_nullVideoSink(0), m_bus(0), m_renderer(0), m_volume(100), m_playbackRate(1.0), m_muted(false), m_audioAvailable(false), m_videoAvailable(false), m_seekable(false), m_lastPosition(0), m_duration(-1) { static bool initialized = false; if (!initialized) { initialized = true; gst_init(NULL, NULL); } #ifdef USE_PLAYBIN2 m_playbin = gst_element_factory_make("playbin2", NULL); #else m_playbin = gst_element_factory_make("playbin", NULL); #endif m_videoOutputBin = gst_bin_new("video-output-bin"); gst_object_ref(GST_OBJECT(m_videoOutputBin)); m_videoIdentity = gst_element_factory_make("identity", "identity-vo"); m_colorSpace = gst_element_factory_make("ffmpegcolorspace", "ffmpegcolorspace-vo"); m_videoScale = gst_element_factory_make("videoscale","videoscale-vo"); m_nullVideoSink = gst_element_factory_make("fakesink", NULL); gst_object_ref(GST_OBJECT(m_nullVideoSink)); gst_bin_add_many(GST_BIN(m_videoOutputBin), m_videoIdentity, m_colorSpace, m_videoScale, m_nullVideoSink, NULL); gst_element_link_many(m_videoIdentity, m_colorSpace, m_videoScale, m_nullVideoSink, NULL); m_videoSink = m_nullVideoSink; // add ghostpads GstPad *pad = gst_element_get_static_pad(m_videoIdentity,"sink"); gst_element_add_pad(GST_ELEMENT(m_videoOutputBin), gst_ghost_pad_new("videosink", pad)); gst_object_unref(GST_OBJECT(pad)); if (m_playbin != 0) { // Sort out messages m_bus = gst_element_get_bus(m_playbin); m_busHelper = new QGstreamerBusHelper(m_bus, this); connect(m_busHelper, SIGNAL(message(QGstreamerMessage)), SLOT(busMessage(QGstreamerMessage))); m_busHelper->installSyncEventFilter(this); g_object_set(G_OBJECT(m_playbin), "video-sink", m_videoOutputBin, NULL); // Initial volume double volume = 1.0; g_object_get(G_OBJECT(m_playbin), "volume", &volume, NULL); m_volume = int(volume*100); } }