Skip to content

Commit d1fa303

Browse files
committed
Fixes to gstreamer pipelines and Camera AVStreamManager Init
1 parent b499d85 commit d1fa303

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

examples/camera-app/camera-common/src/camera-app.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ void CameraAppInit(CameraDeviceInterface * cameraDevice)
7878
{
7979
gCameraApp = Platform::MakeUnique<CameraApp>(kCameraEndpointId, cameraDevice);
8080
gCameraApp.get()->InitCameraDeviceClusters();
81+
82+
ChipLogDetail(NotSpecified, "CameraAppInit: Initialized Camera clusters");
8183
}
8284

8385
void CameraAppShutdown()
8486
{
87+
ChipLogDetail(NotSpecified, "CameraAppShutdown: Shutting down Camera app");
8588
gCameraApp = nullptr;
8689
}

examples/camera-app/linux/BUILD.gn

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ executable("chip-camera-app") {
5353
]
5454

5555
libs = [ "datachannel" ]
56-
5756
lib_dirs =
5857
[ rebase_path("${chip_root}/third_party/libdatachannel/repo/build") ]
5958

@@ -76,7 +75,7 @@ executable("chip-camera-app") {
7675
output_dir = root_out_dir
7776

7877
# Manually specify GStreamer libraries
79-
libs = [
78+
libs += [
8079
"gstreamer-1.0",
8180
"glib-2.0",
8281
"gobject-2.0",

examples/camera-app/linux/include/camera-device.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class CameraDevice : public CameraDeviceInterface,
142142
void InitializeSnapshotStreams();
143143

144144
GstElement * CreatePipeline(const std::string & pipelineString, CameraError& error);
145-
CameraError SetV4l2Control(int controlId, int value);
145+
CameraError SetV4l2Control(uint32_t controlId, int value);
146146

147147
// Various cluster server delegates
148148
ChimeManager mChimeManager;

examples/camera-app/linux/include/clusters/camera-avstream-mgmt/camera-av-stream-manager.h

-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ class CameraAVStreamManager : public CameraAVStreamMgmtDelegate
9696

9797
CHIP_ERROR PersistentAttributesLoadedCallback();
9898

99-
void Init();
100-
10199
CameraAVStreamManager() = default;
102100
~CameraAVStreamManager() = default;
103101

examples/camera-app/linux/src/camera-device.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ CameraDevice::CameraDevice()
3636
{
3737
InitializeCameraDevice();
3838

39-
// set up the different modules/components
40-
mCameraAVStreamManager.Init();
39+
InitializeStreams();
4140
}
4241

4342
CameraDevice::~CameraDevice()
@@ -76,6 +75,8 @@ CameraError CameraDevice::InitializeStreams()
7675
InitializeAudioStreams();
7776
InitializeSnapshotStreams();
7877

78+
StartVideoStream(1);
79+
StartSnapshotStream(1);
7980
return CameraError::SUCCESS;
8081
}
8182

@@ -184,7 +185,7 @@ GstElement* CameraDevice::CreatePipeline(const std::string & pipelineString, Cam
184185
}
185186

186187
// Helper function to set V4L2 control
187-
CameraError CameraDevice::SetV4l2Control(int controlId, int value)
188+
CameraError CameraDevice::SetV4l2Control(uint32_t controlId, int value)
188189
{
189190
if (videoDeviceFd == -1)
190191
{
@@ -230,7 +231,7 @@ CameraError CameraDevice::StartVideoStream(uint16_t streamID)
230231

231232
if (it->codec == VideoCodecEnum::kH264)
232233
{
233-
pipelineString += "x264enc ! rtph264pay ! ";
234+
pipelineString += "videoconvert ! videoscale ! x264enc tune=zerolatency ! rtph264pay ! ";
234235
}
235236
else if (it->codec == VideoCodecEnum::kHevc)
236237
{
@@ -241,7 +242,8 @@ CameraError CameraDevice::StartVideoStream(uint16_t streamID)
241242
return CameraError::ERROR_VIDEO_STREAM_START_FAILED;
242243
}
243244

244-
pipelineString += "udpsink host=127.0.0.1 port=" + VIDEO_STREAM_GST_DEST_PORT; // Known socket
245+
//pipelineString += "udpsink host=127.0.0.1 port=" + VIDEO_STREAM_GST_DEST_PORT; // Known socket
246+
pipelineString += "udpsink host=127.0.0.1 port=5000"; // Known socket
245247

246248
CameraError error = CameraError::SUCCESS;
247249
it->videoPipeline = CreatePipeline(pipelineString, error);
@@ -298,10 +300,12 @@ CameraError CameraDevice::StartSnapshotStream(uint16_t streamID)
298300
return CameraError::ERROR_SNAPSHOT_STREAM_START_FAILED;
299301
}
300302

303+
#if 0
301304
// Construct the GStreamer pipeline string
302305
std::string pipelineString = "v4l2src device=/dev/video0 ! "
303-
"video/x-raw,width=" + std::to_string(it->videoRes.width) +
304-
",height=" + std::to_string(it->videoRes.height) + " ! ";
306+
//"video/x-raw,width=" + std::to_string(it->videoRes.width) +
307+
"image/jpeg,width=" + std::to_string(it->videoRes.width) +
308+
",height=" + std::to_string(it->videoRes.height) + ",framerate=1/1 ! ";
305309

306310
if (it->codec == ImageCodecEnum::kJpeg)
307311
{
@@ -311,7 +315,9 @@ CameraError CameraDevice::StartSnapshotStream(uint16_t streamID)
311315
{
312316
return CameraError::ERROR_SNAPSHOT_STREAM_START_FAILED;
313317
}
318+
#endif
314319

320+
std::string pipelineString = "v4l2src device=/dev/video0 ! videoconvert ! jpegenc snapshot=true ! ";
315321
pipelineString += "filesink location=./capture_snapshot.jpg";
316322

317323
// Create the GStreamer pipeline

examples/camera-app/linux/src/clusters/camera-avstream-mgmt/camera-av-stream-manager.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,3 @@ CameraAVStreamManager::PersistentAttributesLoadedCallback()
213213

214214
return CHIP_NO_ERROR;
215215
}
216-
217-
void CameraAVStreamManager::Init()
218-
{
219-
CameraDevice::GetInstance().InitializeStreams();
220-
}
221-

0 commit comments

Comments
 (0)