Skip to content

Adding packet trailer support to python SDK#658

Open
chenosaurus wants to merge 5 commits into
mainfrom
dc/features/packet_trailer
Open

Adding packet trailer support to python SDK#658
chenosaurus wants to merge 5 commits into
mainfrom
dc/features/packet_trailer

Conversation

@chenosaurus
Copy link
Copy Markdown
Contributor

  • add support for new packet trailer features in Python SDK to attach user timestamp & frame ID to video frames.
  • add examples/local_video to demonstrate publishing video from webcam with timestamping & frame ID.

devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines +728 to +744
elif which == "local_track_republished":
republished = event.local_track_republished
publications = self.local_participant._track_publications
lpublication = publications.pop(republished.previous_sid, None)
if lpublication is None:
logging.warning(
"received local_track_republished for unknown publication sid %s",
republished.previous_sid,
)
return

lpublication._ffi_handle.dispose()
lpublication._ffi_handle = FfiHandle(republished.publication_handle)
lpublication._info.CopyFrom(republished.info)
if lpublication.track is not None:
lpublication.track._info.sid = lpublication.sid
publications[lpublication.sid] = lpublication
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 _first_subscription Future not reset after republish causes InvalidStateError on re-subscribe

After a full reconnect, the local_track_republished handler reuses the existing LocalTrackPublication object but does not reset its _first_subscription future (livekit-rtc/livekit/rtc/track_publication.py:87). When the track is subsequently re-subscribed by a remote participant, the local_track_subscribed handler at livekit-rtc/livekit/rtc/room.py:748 calls lpublication._first_subscription.set_result(None) on an already-completed asyncio.Future, raising InvalidStateError. This exception is caught by _listen_task at livekit-rtc/livekit/rtc/room.py:668-675, but it prevents the self.emit("local_track_subscribed", lpublication.track) call at line 749 from executing, silently suppressing the event for any listeners.

Suggested change
elif which == "local_track_republished":
republished = event.local_track_republished
publications = self.local_participant._track_publications
lpublication = publications.pop(republished.previous_sid, None)
if lpublication is None:
logging.warning(
"received local_track_republished for unknown publication sid %s",
republished.previous_sid,
)
return
lpublication._ffi_handle.dispose()
lpublication._ffi_handle = FfiHandle(republished.publication_handle)
lpublication._info.CopyFrom(republished.info)
if lpublication.track is not None:
lpublication.track._info.sid = lpublication.sid
publications[lpublication.sid] = lpublication
elif which == "local_track_republished":
republished = event.local_track_republished
publications = self.local_participant._track_publications
lpublication = publications.pop(republished.previous_sid, None)
if lpublication is None:
logging.warning(
"received local_track_republished for unknown publication sid %s",
republished.previous_sid,
)
return
lpublication._ffi_handle.dispose()
lpublication._ffi_handle = FfiHandle(republished.publication_handle)
lpublication._info.CopyFrom(republished.info)
lpublication._first_subscription = asyncio.Future()
if lpublication.track is not None:
lpublication.track._info.sid = lpublication.sid
publications[lpublication.sid] = lpublication
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant