Skip to content

Commit 31fac42

Browse files
LocalDataTrack: make proto constructor private
1 parent 1bdfc79 commit 31fac42

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

include/livekit/local_data_track.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,11 @@ class LocalDataTrack {
6868
/// Whether the track is still published in the room.
6969
bool isPublished() const;
7070

71-
/// Construct from an owned proto (called by LocalParticipant).
72-
explicit LocalDataTrack(const proto::OwnedLocalDataTrack &owned);
73-
7471
private:
7572
friend class LocalParticipant;
7673

77-
/// Raw FFI handle id for internal use.
74+
explicit LocalDataTrack(const proto::OwnedLocalDataTrack &owned);
75+
7876
uintptr_t ffi_handle_id() const noexcept { return handle_.get(); }
7977

8078
/** RAII wrapper for the Rust-owned FFI resource. */

include/livekit/remote_data_track.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ class RemoteDataTrack {
6060
return publisher_identity_;
6161
}
6262

63-
/// Raw FFI handle id for internal use.
64-
uintptr_t ffi_handle_id() const noexcept { return handle_.get(); }
65-
6663
/// Whether the track is still published by the remote participant.
6764
bool isPublished() const;
6865

@@ -77,10 +74,12 @@ class RemoteDataTrack {
7774
std::shared_ptr<DataTrackSubscription>
7875
subscribe(const DataTrackSubscription::Options &options = {});
7976

80-
/// Construct from an owned proto (called by Room event handling).
77+
private:
78+
friend class Room;
79+
8180
explicit RemoteDataTrack(const proto::OwnedRemoteDataTrack &owned);
8281

83-
private:
82+
uintptr_t ffi_handle_id() const noexcept { return handle_.get(); }
8483
/** RAII wrapper for the Rust-owned FFI resource. */
8584
FfiHandle handle_;
8685

src/local_participant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ LocalParticipant::publishDataTrack(const std::string &name) {
237237
static_cast<std::uint64_t>(handle_id), name);
238238

239239
proto::OwnedLocalDataTrack owned = fut.get();
240-
return std::make_shared<LocalDataTrack>(owned);
240+
return std::shared_ptr<LocalDataTrack>(new LocalDataTrack(owned));
241241
}
242242

243243
void LocalParticipant::unpublishDataTrack(

src/room.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@ void Room::OnEvent(const FfiEvent &event) {
606606
}
607607
case proto::RoomEvent::kRemoteDataTrackPublished: {
608608
const auto &rdtp = re.remote_data_track_published();
609-
auto remote_track = std::make_shared<RemoteDataTrack>(rdtp.track());
609+
auto remote_track =
610+
std::shared_ptr<RemoteDataTrack>(new RemoteDataTrack(rdtp.track()));
610611
std::cout << "[Room] RoomEvent::kRemoteDataTrackPublished: \""
611612
<< remote_track->info().name << "\" from \""
612613
<< remote_track->publisherIdentity()

0 commit comments

Comments
 (0)