RsMediaSession.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #include "GroupsockHelper.hh"
5 #include "Locale.hh"
6 #include "liveMedia.hh"
7 
8 #include "RsCommon.h"
9 #include "RsMediaSession.hh"
10 
11 #include <ctype.h>
12 #include <iostream>
13 
14 // RsMediaSession
15 
16 RsMediaSession* RsMediaSession::createNew(UsageEnvironment& env, char const* sdpDescription)
17 {
18  RsMediaSession* newSession = new RsMediaSession(env);
19  if(newSession != NULL)
20  {
21  if(!newSession->initializeWithSDP(sdpDescription))
22  {
23  delete newSession;
24  return NULL;
25  }
26  }
27  return newSession;
28 }
29 
30 RsMediaSession::RsMediaSession(UsageEnvironment& env)
31  : MediaSession(env)
32 {}
33 
35 
37 {
38  // default implementation:
39  return new RsMediaSubsession(*this);
40 }
41 
42 // RsMediaSubsessionIterator
43 
45  : fOurSession(session)
46 {
47  reset();
48 }
49 
51 
53 {
55 
56  if(fNextPtr != NULL)
57  fNextPtr = (RsMediaSubsession*)(fNextPtr->fNext);
58 
59  return result;
60 }
61 
63 {
64  fNextPtr = (RsMediaSubsession*)(fOurSession.fSubsessionsHead);
65 }
66 
67 // MediaSubsession
68 
70  : MediaSubsession(parent)
71 {}
72 
74 {
75  if(sink != NULL)
76  {
77  Medium::close(sink);
78  }
79 }
80 
81 Boolean RsMediaSubsession::createSourceObjects(int useSpecialRTPoffset)
82 {
83  if(strcmp(fCodecName, RS_PAYLOAD_FORMAT.c_str()) == 0)
84  {
85  // This subsession uses our custom RTP payload format:
86  std::string mimeTypeString = RS_MEDIA_TYPE + "/" + RS_PAYLOAD_FORMAT;
87  fReadSource = fRTPSource = SimpleRTPSource::createNew(env(), fRTPSocket, fRTPPayloadFormat, fRTPTimestampFrequency, mimeTypeString.c_str());
88 
89 #if defined(_WIN32)
90  if(rtpSource() != NULL)
91  {
92  // configure a time threshold
93  // for reordering misordered incoming packets:
94  unsigned const thresh = 33000; // 33 ms
95  rtpSource()->setPacketReorderingThresholdTime(thresh);
96 
97  // Set the RTP source's OS socket buffer size as appropriate
98  int socketNum = rtpSource()->RTPgs()->socketNum();
99  unsigned curBufferSize = getReceiveBufferSize(env(), socketNum);
100  unsigned newBufferSize = 1024 * 1024 * 8; // 8M
101  newBufferSize = setReceiveBufferTo(env(), socketNum, newBufferSize);
102  env() << "Changed socket receive buffer size for the \"" << mediumName() << "/" << codecName() << "\" subsession from " << curBufferSize << " to " << newBufferSize << " bytes\n";
103  }
104 #endif
105  return True;
106  }
107  else
108  {
109  // This subsession uses some other RTP payload format - perhaps one that we already implement:
110  return MediaSubsession::createSourceObjects(useSpecialRTPoffset);
111  }
112 }
virtual ~RsMediaSubsession()
const std::string RS_MEDIA_TYPE("RS_VIDEO")
static RsMediaSession * createNew(UsageEnvironment &env, char const *sdpDescription)
RsMediaSubsessionIterator(RsMediaSession const &session)
virtual ~RsMediaSession()
GLsizei const GLchar *const * string
GLsizei GLenum GLboolean sink
Definition: glext.h:3601
RsMediaSubsession * fNextPtr
RsMediaSession const & fOurSession
RsMediaSubsession(RsMediaSession &parent)
RsMediaSubsession * next()
virtual MediaSubsession * createNewMediaSubsession()
RsMediaSession(UsageEnvironment &env)
virtual Boolean createSourceObjects(int useSpecialRTPoffset)
const std::string RS_PAYLOAD_FORMAT("RS_FORMAT")
#define NULL
Definition: tinycthread.c:47
GLuint64EXT * result
Definition: glext.h:10921


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41