Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2025
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | Source Code | 0 0
  1. LiveServerMediaSubsession* LiveServerMediaSubsession::createNew( UsageEnvironment& env )
  2. {
  3.     return new LiveServerMediaSubsession( env );
  4. }
  5.  
  6. LiveServerMediaSubsession::LiveServerMediaSubsession( UsageEnvironment& env )
  7.     : OnDemandServerMediaSubsession( env, True /* reuseFirstSource */ )
  8. {
  9. }
  10.  
  11. LiveServerMediaSubsession::~LiveServerMediaSubsession()
  12. {
  13. }
  14.  
  15. FramedSource* LiveServerMediaSubsession::createNewStreamSource( unsigned clientSessionId, unsigned& estBitrate )
  16. {
  17.     // Get the existing singleton instance
  18.     auto src = V4l2MJPEGSource::createNew( envir( ) );
  19.     if ( src == nullptr ) {
  20.         envir( ) << "Failed to create V4l2MJPEGSource\n";
  21.         return nullptr;
  22.     }
  23.    
  24.     // Estimate bitrate based on typical MJPEG compression ratio
  25.     // Assuming 1920x1080 at 90fps with ~1:10 compression ratio
  26.     estBitrate = 1920 * 1080 * 90 * 3 / 10;  // Rough estimate in bits per second
  27.    
  28.     return src;
  29. }
  30.  
  31. RTPSink* LiveServerMediaSubsession::createNewRTPSink( Groupsock* rtpGroupsock,
  32.                                                       unsigned char rtpPayloadTypeIfDynamic,
  33.                                                       FramedSource* inputSource )
  34. {
  35.     if ( rtpGroupsock == nullptr ) {
  36.         envir( ) << "Invalid RTP groupsock\n";
  37.         return nullptr;
  38.     }
  39.    
  40.     // Create JPEG RTP sink with specific parameters
  41.     auto sink = JPEGVideoRTPSink::createNew( envir( ), rtpGroupsock );
  42.     if ( sink == nullptr ) {
  43.         envir( ) << "Failed to create JPEG RTP sink\n";
  44.         return nullptr;
  45.     }
  46.    
  47.     // Set maximum packet size to avoid fragmentation
  48.     sink->setPacketSizes(1000, 1448);
  49.    
  50.     return sink;
  51. }
Tags: live555
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement