Skip to content

Commit 5df24e6

Browse files
authored
Integrate PushAvStreamTransport into camera app (project-chip#40573)
1 parent 9b4157f commit 5df24e6

File tree

8 files changed

+58
-44
lines changed

8 files changed

+58
-44
lines changed

examples/camera-app/camera-common/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ source_set("camera-lib") {
5151

5252
deps = [
5353
"${chip_root}/examples/camera-app/camera-common",
54-
"${chip_root}/src/app/clusters/push-av-stream-transport-server:push-av-stream-transport-server",
54+
"${chip_root}/src/app/clusters/push-av-stream-transport-server",
5555
"${chip_root}/src/lib",
5656
]
5757
}

examples/camera-app/camera-common/include/camera-device-interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class CameraDeviceInterface
139139
virtual MediaController & GetMediaController() = 0;
140140

141141
// Getter for PushAVStreamTransport Delegate
142-
virtual chip::app::Clusters::PushAvStreamTransportDelegate & GetPushAVDelegate() = 0;
142+
virtual chip::app::Clusters::PushAvStreamTransportDelegate & GetPushAVTransportDelegate() = 0;
143143

144144
// Class defining the Camera HAL interface
145145
class CameraHALInterface

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ CameraApp::CameraApp(chip::EndpointId aClustersEndpoint, CameraDeviceInterface *
4444
mWebRTCTransportProviderPtr =
4545
std::make_unique<WebRTCTransportProviderServer>(mCameraDevice->GetWebRTCProviderDelegate(), mEndpoint);
4646

47-
Clusters::PushAvStreamTransport::SetDelegate(mEndpoint, &(mCameraDevice->GetPushAVDelegate()));
47+
Clusters::PushAvStreamTransport::SetDelegate(mEndpoint, &(mCameraDevice->GetPushAVTransportDelegate()));
4848

4949
// Fetch all initialization parameters for CameraAVStreamMgmt Server
5050
BitFlags<CameraAvStreamManagement::Feature> avsmFeatures;

examples/camera-app/linux/BUILD.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ config("config") {
3636
"include",
3737
"include/clusters/chime",
3838
"include/clusters/webrtc-provider",
39-
"include/clusters/push_av_transport",
4039
"include/clusters/camera-avstream-mgmt",
4140
"include/clusters/camera-avsettingsuserlevel-mgmt",
41+
"include/clusters/push-av-stream-transport",
4242
"include/clusters/zone-mgmt",
4343
"include/media-controller",
4444
"include/transport",
@@ -83,7 +83,7 @@ executable("chip-camera-app") {
8383
"${chip_root}/examples/camera-app/linux/src/clusters/camera-avsettingsuserlevel-mgmt/camera-avsettingsuserlevel-manager.cpp",
8484
"${chip_root}/examples/camera-app/linux/src/clusters/camera-avstream-mgmt/camera-av-stream-manager.cpp",
8585
"${chip_root}/examples/camera-app/linux/src/clusters/chime/chime-manager.cpp",
86-
"${chip_root}/examples/camera-app/linux/src/clusters/push_av_transport/push-av-stream-transport-delegate-impl.cpp",
86+
"${chip_root}/examples/camera-app/linux/src/clusters/push-av-stream-transport/push-av-stream-manager.cpp",
8787
"${chip_root}/examples/camera-app/linux/src/clusters/webrtc-provider/webrtc-provider-manager.cpp",
8888
"${chip_root}/examples/camera-app/linux/src/clusters/zone-mgmt/zone-manager.cpp",
8989
"${chip_root}/examples/camera-app/linux/src/media-controller/default-media-controller.cpp",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "camera-avsettingsuserlevel-manager.h"
2222
#include "camera-device-interface.h"
2323
#include "chime-manager.h"
24-
#include "push-av-stream-transport-delegate-impl.h"
24+
#include "push-av-stream-manager.h"
2525
#include "webrtc-provider-manager.h"
2626
#include "zone-manager.h"
2727

@@ -87,7 +87,7 @@ class CameraDevice : public CameraDeviceInterface, public CameraDeviceInterface:
8787
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamMgmtDelegate & GetCameraAVStreamMgmtDelegate() override;
8888
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamController & GetCameraAVStreamMgmtController() override;
8989
chip::app::Clusters::CameraAvSettingsUserLevelManagement::Delegate & GetCameraAVSettingsUserLevelMgmtDelegate() override;
90-
chip::app::Clusters::PushAvStreamTransportDelegate & GetPushAVDelegate() override;
90+
chip::app::Clusters::PushAvStreamTransportDelegate & GetPushAVTransportDelegate() override;
9191
chip::app::Clusters::ZoneManagement::Delegate & GetZoneManagementDelegate() override;
9292

9393
MediaController & GetMediaController() override;
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
*/
1818

1919
#pragma once
20+
#include <app-common/zap-generated/cluster-enums.h>
2021
#include <app/clusters/push-av-stream-transport-server/push-av-stream-transport-cluster.h>
21-
#include <app/util/config.h>
22-
#include <lib/support/logging/CHIPLogging.h>
23-
#include <vector>
2422

25-
#include "camera-device-interface.h"
26-
#include <app-common/zap-generated/cluster-enums.h>
23+
#include <camera-device-interface.h>
2724
#include <media-controller.h>
2825
#include <pushav-transport.h>
26+
2927
#include <unordered_map>
28+
#include <vector>
3029

3130
namespace chip {
3231
namespace app {
@@ -47,6 +46,13 @@ struct PushAvStream
4746
class PushAvStreamTransportManager : public PushAvStreamTransportDelegate
4847
{
4948
public:
49+
PushAvStreamTransportManager() = default;
50+
~PushAvStreamTransportManager();
51+
52+
void Init();
53+
void SetMediaController(MediaController * mediaController);
54+
void SetCameraDevice(CameraDeviceInterface * cameraDevice);
55+
5056
Protocols::InteractionModel::Status AllocatePushTransport(const TransportOptionsStruct & transportOptions,
5157
const uint16_t connectionID);
5258
Protocols::InteractionModel::Status DeallocatePushTransport(const uint16_t connectionID);
@@ -78,12 +84,6 @@ class PushAvStreamTransportManager : public PushAvStreamTransportDelegate
7884
CHIP_ERROR LoadCurrentConnections(std::vector<TransportConfigurationStorage> & currentConnections);
7985
CHIP_ERROR PersistentAttributesLoadedCallback();
8086

81-
void SetMediaController(MediaController * mediaController);
82-
void SetCameraDevice(CameraDeviceInterface * cameraDevice);
83-
void Init();
84-
85-
~PushAvStreamTransportManager();
86-
8787
private:
8888
std::vector<PushAvStream> pushavStreams;
8989
MediaController * mMediaController = nullptr;

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,14 +1226,27 @@ void CameraDevice::InitializeVideoStreams()
12261226

12271227
void CameraDevice::InitializeAudioStreams()
12281228
{
1229-
// Create single audio stream with typical supported parameters
1230-
AudioStream audioStream = { { 1 /* Id */, StreamUsageEnum::kLiveView /* StreamUsage */, AudioCodecEnum::kOpus,
1231-
kMicrophoneMaxChannelCount /* ChannelCount(Max from Spec) */, 48000 /* SampleRate */,
1232-
30000 /* BitRate*/, 24 /* BitDepth */, 0 /* RefCount */ },
1233-
false,
1234-
nullptr };
1235-
1236-
mAudioStreams.push_back(audioStream);
1229+
// Mono stream
1230+
AudioStream monoStream = { { 1 /* Id */, StreamUsageEnum::kLiveView, AudioCodecEnum::kOpus, 1 /* ChannelCount: Mono */,
1231+
48000 /* SampleRate */, 20000 /* BitRate */, 24 /* BitDepth */, 0 /* RefCount */ },
1232+
false,
1233+
nullptr };
1234+
mAudioStreams.push_back(monoStream);
1235+
1236+
// Stereo stream
1237+
AudioStream stereoStream = { { 2 /* Id */, StreamUsageEnum::kLiveView, AudioCodecEnum::kOpus, 2 /* ChannelCount: Stereo */,
1238+
48000 /* SampleRate */, 32000 /* BitRate */, 24 /* BitDepth */, 0 /* RefCount */ },
1239+
false,
1240+
nullptr };
1241+
mAudioStreams.push_back(stereoStream);
1242+
1243+
// Max channel count stream (from spec constant)
1244+
AudioStream maxChannelStream = { { 3 /* Id */, StreamUsageEnum::kLiveView, AudioCodecEnum::kOpus,
1245+
kMicrophoneMaxChannelCount /* Max from Spec */, 48000 /* SampleRate */, 64000 /* BitRate */,
1246+
24 /* BitDepth */, 0 /* RefCount */ },
1247+
false,
1248+
nullptr };
1249+
mAudioStreams.push_back(maxChannelStream);
12371250
}
12381251

12391252
void CameraDevice::InitializeSnapshotStreams()
@@ -1266,7 +1279,7 @@ WebRTCTransportProvider::Delegate & CameraDevice::GetWebRTCProviderDelegate()
12661279
return mWebRTCProviderManager;
12671280
}
12681281

1269-
PushAvStreamTransportDelegate & CameraDevice::GetPushAVDelegate()
1282+
PushAvStreamTransportDelegate & CameraDevice::GetPushAVTransportDelegate()
12701283
{
12711284
return mPushAVTransportManager;
12721285
}
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
* limitations under the License.
1717
*/
1818

19+
#include "push-av-stream-manager.h"
20+
1921
#include <app-common/zap-generated/attributes/Accessors.h>
2022
#include <app-common/zap-generated/ids/Attributes.h>
2123
#include <app-common/zap-generated/ids/Clusters.h>
2224
#include <fstream>
2325
#include <iostream>
2426
#include <lib/support/logging/CHIPLogging.h>
25-
#include <push-av-stream-transport-delegate-impl.h>
2627

2728
using namespace chip;
2829
using namespace chip::app;
@@ -31,16 +32,6 @@ using namespace chip::app::Clusters;
3132
using namespace chip::app::Clusters::PushAvStreamTransport;
3233
using chip::Protocols::InteractionModel::Status;
3334

34-
void PushAvStreamTransportManager::SetMediaController(MediaController * mediaController)
35-
{
36-
mMediaController = mediaController;
37-
}
38-
39-
void PushAvStreamTransportManager::SetCameraDevice(CameraDeviceInterface * aCameraDevice)
40-
{
41-
mCameraDevice = aCameraDevice;
42-
}
43-
4435
PushAvStreamTransportManager::~PushAvStreamTransportManager()
4536
{
4637
// Unregister all transports from Media Controller before deleting them. This will ensure that any ongoing streams are
@@ -56,6 +47,22 @@ PushAvStreamTransportManager::~PushAvStreamTransportManager()
5647
mTransportOptionsMap.clear();
5748
}
5849

50+
void PushAvStreamTransportManager::Init()
51+
{
52+
ChipLogProgress(Zcl, "Push AV Stream Transport Initialized");
53+
return;
54+
}
55+
56+
void PushAvStreamTransportManager::SetMediaController(MediaController * mediaController)
57+
{
58+
mMediaController = mediaController;
59+
}
60+
61+
void PushAvStreamTransportManager::SetCameraDevice(CameraDeviceInterface * aCameraDevice)
62+
{
63+
mCameraDevice = aCameraDevice;
64+
}
65+
5966
Protocols::InteractionModel::Status
6067
PushAvStreamTransportManager::AllocatePushTransport(const TransportOptionsStruct & transportOptions, const uint16_t connectionID)
6168
{
@@ -362,12 +369,6 @@ void PushAvStreamTransportManager::OnAttributeChanged(AttributeId attributeId)
362369
ChipLogProgress(Zcl, "Attribute changed for AttributeId = " ChipLogFormatMEI, ChipLogValueMEI(attributeId));
363370
}
364371

365-
void PushAvStreamTransportManager::Init()
366-
{
367-
ChipLogProgress(Zcl, "Push AV Stream Transport Initialized");
368-
return;
369-
}
370-
371372
CHIP_ERROR PushAvStreamTransportManager::LoadCurrentConnections(std::vector<TransportConfigurationStorage> & currentConnections)
372373
{
373374
ChipLogProgress(Zcl, "Push AV Current Connections loaded");

0 commit comments

Comments
 (0)