summaryrefslogtreecommitdiff
path: root/sys/avc
diff options
context:
space:
mode:
authorQuentin Smith <quentin@mit.edu>2011-04-18 15:37:57 -0400
committerDavid Schleef <ds@schleef.org>2011-05-18 12:06:38 -0700
commit004f2541e4ba5c8517fe103b9cf3130d0c3784f8 (patch)
treeefe5297e732cd38e1a6f6e294c211fb858272ba4 /sys/avc
parent7ac4cd7ef55c4d62043b8baab133a03933ef9a40 (diff)
downloadgstreamer-plugins-bad-004f2541e4ba5c8517fe103b9cf3130d0c3784f8.tar.gz
avc: Save AVC objects in the GstAVCSrc object
and stop them when the pipeline is stopped
Diffstat (limited to 'sys/avc')
-rw-r--r--sys/avc/gstavcsrc.cpp44
-rw-r--r--sys/avc/gstavcsrc.h7
2 files changed, 30 insertions, 21 deletions
diff --git a/sys/avc/gstavcsrc.cpp b/sys/avc/gstavcsrc.cpp
index 32aaa8d6d..321907089 100644
--- a/sys/avc/gstavcsrc.cpp
+++ b/sys/avc/gstavcsrc.cpp
@@ -250,12 +250,6 @@ static gboolean
gst_avc_src_start (GstBaseSrc * 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");
@@ -263,8 +257,9 @@ gst_avc_src_start (GstBaseSrc * src)
#ifdef ENABLE
// Create a AVCDeviceController
- CreateAVCDeviceController (&pAVCDeviceController);
- if (!pAVCDeviceController) {
+ if (!avcsrc->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
GST_ERROR ("Failed to create AVC device controller.");
return FALSE;
@@ -272,35 +267,35 @@ gst_avc_src_start (GstBaseSrc * src)
GST_INFO ("Created AVC device controller.");
- if (deviceIndex >= CFArrayGetCount (pAVCDeviceController->avcDeviceArray)) {
- GST_ERROR ("Failed to find AVC device %d", deviceIndex);
+ if (avcsrc->deviceIndex >= CFArrayGetCount (avcsrc->pAVCDeviceController->avcDeviceArray)) {
+ GST_ERROR ("Failed to find AVC device %d", avcsrc->deviceIndex);
return FALSE;
}
- pAVCDevice = (AVCDevice *)
- CFArrayGetValueAtIndex (pAVCDeviceController->avcDeviceArray,
- deviceIndex);
+ avcsrc->pAVCDevice = (AVCDevice *)
+ CFArrayGetValueAtIndex (avcsrc->pAVCDeviceController->avcDeviceArray,
+ avcsrc->deviceIndex);
- if (!pAVCDevice) {
- GST_ERROR ("Failed to find AVC device %d", deviceIndex);
+ if (!avcsrc->pAVCDevice) {
+ GST_ERROR ("Failed to find AVC device %d", avcsrc->deviceIndex);
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,
MPEGReceiverMessageReceivedProc,
nil,
nil, kNumCyclesInMPEGReceiverSegment, kNumSegmentsInMPEGReceiverProgram);
- pAVCDeviceStream->pMPEGReceiver->registerStructuredDataPushCallback
+ avcsrc->pAVCDeviceStream->pMPEGReceiver->registerStructuredDataPushCallback
(MyStructuredDataPushProc,
kNumCyclesInMPEGReceiverSegment, (void *) avcsrc);
- pAVCDevice->StartAVCDeviceStream (pAVCDeviceStream);
+ avcsrc->pAVCDevice->StartAVCDeviceStream (avcsrc->pAVCDeviceStream);
#endif
return TRUE;
@@ -314,7 +309,14 @@ gst_avc_src_stop (GstBaseSrc * src)
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) {
gst_buffer_unref (buffer);
diff --git a/sys/avc/gstavcsrc.h b/sys/avc/gstavcsrc.h
index bcf14f4c6..9d1f0bd93 100644
--- a/sys/avc/gstavcsrc.h
+++ b/sys/avc/gstavcsrc.h
@@ -21,6 +21,8 @@
#define _GST_AVC_SRC_H_
#include <gst/base/gstbasesrc.h>
+#include <AVCVideoServices/AVCVideoServices.h>
+using namespace AVS;
G_BEGIN_DECLS
@@ -39,6 +41,11 @@ struct _GstAVCSrc
GstPad *srcpad;
+ AVCDeviceController *pAVCDeviceController;
+ AVCDevice *pAVCDevice;
+ AVCDeviceStream *pAVCDeviceStream;
+ int deviceIndex;
+
GstAtomicQueue *queue;
GCond *cond;
GMutex *queue_lock;