mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-06 02:32:23 +00:00
avc: Save AVC objects in the GstAVCSrc object
and stop them when the pipeline is stopped
This commit is contained in:
parent
7ac4cd7ef5
commit
004f2541e4
2 changed files with 30 additions and 21 deletions
|
@ -250,12 +250,6 @@ static gboolean
|
||||||
gst_avc_src_start (GstBaseSrc * src)
|
gst_avc_src_start (GstBaseSrc * src)
|
||||||
{
|
{
|
||||||
GstAVCSrc *avcsrc = GST_AVC_SRC (src);
|
GstAVCSrc *avcsrc = GST_AVC_SRC (src);
|
||||||
#ifdef ENABLE
|
|
||||||
AVCDeviceController *pAVCDeviceController = nil;
|
|
||||||
AVCDevice *pAVCDevice;
|
|
||||||
AVCDeviceStream *pAVCDeviceStream;
|
|
||||||
int deviceIndex = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (avcsrc, "start");
|
GST_DEBUG_OBJECT (avcsrc, "start");
|
||||||
|
|
||||||
|
@ -263,8 +257,9 @@ gst_avc_src_start (GstBaseSrc * src)
|
||||||
|
|
||||||
#ifdef ENABLE
|
#ifdef ENABLE
|
||||||
// Create a AVCDeviceController
|
// Create a AVCDeviceController
|
||||||
CreateAVCDeviceController (&pAVCDeviceController);
|
if (!avcsrc->pAVCDeviceController)
|
||||||
if (!pAVCDeviceController) {
|
CreateAVCDeviceController (&avcsrc->pAVCDeviceController);
|
||||||
|
if (!avcsrc->pAVCDeviceController) {
|
||||||
// TODO: This should never happen (unless we've run out of memory), but we should handle it cleanly anyway
|
// TODO: This should never happen (unless we've run out of memory), but we should handle it cleanly anyway
|
||||||
GST_ERROR ("Failed to create AVC device controller.");
|
GST_ERROR ("Failed to create AVC device controller.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -272,35 +267,35 @@ gst_avc_src_start (GstBaseSrc * src)
|
||||||
|
|
||||||
GST_INFO ("Created AVC device controller.");
|
GST_INFO ("Created AVC device controller.");
|
||||||
|
|
||||||
if (deviceIndex >= CFArrayGetCount (pAVCDeviceController->avcDeviceArray)) {
|
if (avcsrc->deviceIndex >= CFArrayGetCount (avcsrc->pAVCDeviceController->avcDeviceArray)) {
|
||||||
GST_ERROR ("Failed to find AVC device %d", deviceIndex);
|
GST_ERROR ("Failed to find AVC device %d", avcsrc->deviceIndex);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pAVCDevice = (AVCDevice *)
|
avcsrc->pAVCDevice = (AVCDevice *)
|
||||||
CFArrayGetValueAtIndex (pAVCDeviceController->avcDeviceArray,
|
CFArrayGetValueAtIndex (avcsrc->pAVCDeviceController->avcDeviceArray,
|
||||||
deviceIndex);
|
avcsrc->deviceIndex);
|
||||||
|
|
||||||
if (!pAVCDevice) {
|
if (!avcsrc->pAVCDevice) {
|
||||||
GST_ERROR ("Failed to find AVC device %d", deviceIndex);
|
GST_ERROR ("Failed to find AVC device %d", avcsrc->deviceIndex);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_INFO ("Found device with GUID 0x%016llX\n", pAVCDevice->guid);
|
GST_INFO ("Found device with GUID 0x%016llX\n", avcsrc->pAVCDevice->guid);
|
||||||
|
|
||||||
pAVCDevice->openDevice (nil, nil);
|
avcsrc->pAVCDevice->openDevice (nil, nil);
|
||||||
|
|
||||||
pAVCDeviceStream = pAVCDevice->CreateMPEGReceiverForDevicePlug (0, nil, // We'll install the structured callback later (MyStructuredDataPushProc),
|
avcsrc->pAVCDeviceStream = avcsrc->pAVCDevice->CreateMPEGReceiverForDevicePlug (0, nil, // We'll install the structured callback later (MyStructuredDataPushProc),
|
||||||
nil,
|
nil,
|
||||||
MPEGReceiverMessageReceivedProc,
|
MPEGReceiverMessageReceivedProc,
|
||||||
nil,
|
nil,
|
||||||
nil, kNumCyclesInMPEGReceiverSegment, kNumSegmentsInMPEGReceiverProgram);
|
nil, kNumCyclesInMPEGReceiverSegment, kNumSegmentsInMPEGReceiverProgram);
|
||||||
|
|
||||||
pAVCDeviceStream->pMPEGReceiver->registerStructuredDataPushCallback
|
avcsrc->pAVCDeviceStream->pMPEGReceiver->registerStructuredDataPushCallback
|
||||||
(MyStructuredDataPushProc,
|
(MyStructuredDataPushProc,
|
||||||
kNumCyclesInMPEGReceiverSegment, (void *) avcsrc);
|
kNumCyclesInMPEGReceiverSegment, (void *) avcsrc);
|
||||||
|
|
||||||
pAVCDevice->StartAVCDeviceStream (pAVCDeviceStream);
|
avcsrc->pAVCDevice->StartAVCDeviceStream (avcsrc->pAVCDeviceStream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -314,7 +309,14 @@ gst_avc_src_stop (GstBaseSrc * src)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (avcsrc, "stop");
|
GST_DEBUG_OBJECT (avcsrc, "stop");
|
||||||
|
|
||||||
/* FIXME do whatever is needed to stop capture */
|
// Stop the stream
|
||||||
|
avcsrc->pAVCDevice->StopAVCDeviceStream(avcsrc->pAVCDeviceStream);
|
||||||
|
// Destroy the stream
|
||||||
|
avcsrc->pAVCDevice->DestroyAVCDeviceStream(avcsrc->pAVCDeviceStream);
|
||||||
|
avcsrc->pAVCDeviceStream = nil;
|
||||||
|
|
||||||
|
// Forget about the device (don't destroy it; pAVCDeviceController manages it)
|
||||||
|
avcsrc->pAVCDevice = nil;
|
||||||
|
|
||||||
while ((buffer = GST_BUFFER (gst_atomic_queue_pop (avcsrc->queue))) != NULL) {
|
while ((buffer = GST_BUFFER (gst_atomic_queue_pop (avcsrc->queue))) != NULL) {
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#define _GST_AVC_SRC_H_
|
#define _GST_AVC_SRC_H_
|
||||||
|
|
||||||
#include <gst/base/gstbasesrc.h>
|
#include <gst/base/gstbasesrc.h>
|
||||||
|
#include <AVCVideoServices/AVCVideoServices.h>
|
||||||
|
using namespace AVS;
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -39,6 +41,11 @@ struct _GstAVCSrc
|
||||||
|
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
|
|
||||||
|
AVCDeviceController *pAVCDeviceController;
|
||||||
|
AVCDevice *pAVCDevice;
|
||||||
|
AVCDeviceStream *pAVCDeviceStream;
|
||||||
|
int deviceIndex;
|
||||||
|
|
||||||
GstAtomicQueue *queue;
|
GstAtomicQueue *queue;
|
||||||
GCond *cond;
|
GCond *cond;
|
||||||
GMutex *queue_lock;
|
GMutex *queue_lock;
|
||||||
|
|
Loading…
Reference in a new issue