Document install_receive_hook()

This commit is contained in:
Aaro Altonen 2021-02-23 13:57:55 +02:00
parent 36d76a3ca5
commit 59b4eb4b27
4 changed files with 120 additions and 95 deletions

View File

@ -96,6 +96,7 @@ rtp_error_t&#160;</td><td class="memItemRight" valign="bottom"><b>push_frame</b>
<tr class="memdesc:a441263e19be4383223884fde8838f736"><td class="mdescLeft">&#160;</td><td class="mdescRight">Poll a frame for a specified time from the media stream object. <a href="classuvgrtp_1_1media__stream.html#a441263e19be4383223884fde8838f736">More...</a><br /></td></tr>
<tr class="separator:a441263e19be4383223884fde8838f736"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a74a558b23866976e52c5903996544a27"><td class="memItemLeft" align="right" valign="top">rtp_error_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27">install_receive_hook</a> (void *arg, void(*hook)(void *, uvgrtp::frame::rtp_frame *))</td></tr>
<tr class="memdesc:a74a558b23866976e52c5903996544a27"><td class="mdescLeft">&#160;</td><td class="mdescRight">Asynchronous way of getting frames. <a href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27">More...</a><br /></td></tr>
<tr class="separator:a74a558b23866976e52c5903996544a27"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:addf1cde9cb8c4e4af3160ce24c4288a5"><td class="memItemLeft" align="right" valign="top">rtp_error_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classuvgrtp_1_1media__stream.html#addf1cde9cb8c4e4af3160ce24c4288a5">configure_ctx</a> (int flag, ssize_t value)</td></tr>
<tr class="memdesc:addf1cde9cb8c4e4af3160ce24c4288a5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Configure the media stream, see <a class="el" href="util_8hh.html#aa98d9238629e33567e73af0d239e587f" title="RTP context configuration flags.">RTP_CTX_CONFIGURATION_FLAGS</a> for more details. <a href="classuvgrtp_1_1media__stream.html#addf1cde9cb8c4e4af3160ce24c4288a5">More...</a><br /></td></tr>
@ -198,10 +199,25 @@ rtp_error_t&#160;</td><td class="memItemRight" valign="bottom"><b>push_frame</b>
</tr>
</table>
</div><div class="memdoc">
<p>Alternative to <a class="el" href="classuvgrtp_1_1media__stream.html#ae2fe9e8d9b67e25f103a78a25417149f" title="Poll a frame indefinetily from the media stream object.">pull_frame()</a>. The provided hook is called when a frame is received.</p>
<p>"arg" is optional argument that is passed to hook when it is called. It may be nullptr</p>
<p>NOTE: Hook should not be used to process the frame but it should be a place where the frame handout happens from uvgRTP to application</p>
<p>Return RTP_OK on success Return RTP_INVALID_VALUE if "hook" is nullptr </p>
<p>Asynchronous way of getting frames. </p>
<p>Receive hook is an alternative to polling frames using <a class="el" href="classuvgrtp_1_1media__stream.html#ae2fe9e8d9b67e25f103a78a25417149f" title="Poll a frame indefinetily from the media stream object.">uvgrtp::media_stream::pull_frame()</a>. Instead of application asking from uvgRTP if there are any new frames available, uvgRTP will notify the application when a frame has been received</p>
<p>The hook should not be used for media processing as it will block the receiver from reading more frames. Instead, it should only be used as an interface between uvgRTP and the calling application where the frame hand-off happens.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">arg</td><td>Optional argument that is passed to the hook when it is called, can be set to nullptr </td></tr>
<tr><td class="paramname">hook</td><td>Function pointer to the receive hook that uvgRTP should call</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>RTP error code</dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">RTP_OK</td><td>On success </td></tr>
<tr><td class="paramname">RTP_INVALID_VALUE</td><td>If hook is nullptr </td></tr>
</table>
</dd>
</dl>
</div>
</div>

View File

@ -68,7 +68,7 @@ $(function() {
<div class="textblock"><p><a class="anchor" id="md_docs_html_INDEX"></a> To use uvgRTP, you must first create a <a class="el" href="classuvgrtp_1_1context.html">uvgrtp::context</a> object</p>
<p>Then you need to allocate a <a class="el" href="classuvgrtp_1_1session.html">uvgrtp::session</a> object from the context object by calling <a class="el" href="classuvgrtp_1_1context.html#aa109aa2a419933359d225d19bcf3b2f9" title="Create a new RTP session.">uvgrtp::context::create_session()</a></p>
<p>Finally, you need to allocate a <a class="el" href="classuvgrtp_1_1media__stream.html">uvgrtp::media_stream</a> object from the allocated session object by calling <a class="el" href="classuvgrtp_1_1session.html#a71aad1226214b1b0b1ba60a46c048ab2" title="Create a bidirectional media stream for an RTP session.">uvgrtp::session::create_stream()</a></p>
<p>This object is used for both sending and receiving, see documentation for <a class="el" href="classuvgrtp_1_1media__stream.html#ab2b7507d5b2c76bef74c9bceec07ba18">uvgrtp::media_stream::push_frame()</a>, <a class="el" href="classuvgrtp_1_1media__stream.html#ae2fe9e8d9b67e25f103a78a25417149f" title="Poll a frame indefinetily from the media stream object.">uvgrtp::media_stream::pull_frame()</a> and <a class="el" href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27">uvgrtp::media_stream::install_receive_hook()</a> for more details. </p>
<p>This object is used for both sending and receiving, see documentation for <a class="el" href="classuvgrtp_1_1media__stream.html#ab2b7507d5b2c76bef74c9bceec07ba18">uvgrtp::media_stream::push_frame()</a>, <a class="el" href="classuvgrtp_1_1media__stream.html#ae2fe9e8d9b67e25f103a78a25417149f" title="Poll a frame indefinetily from the media stream object.">uvgrtp::media_stream::pull_frame()</a> and <a class="el" href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27" title="Asynchronous way of getting frames.">uvgrtp::media_stream::install_receive_hook()</a> for more details. </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
<!-- start footer part -->

View File

@ -136,95 +136,95 @@ $(function() {
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; </div>
<div class="line"><a name="l00119"></a><span class="lineno"><a class="line" href="classuvgrtp_1_1media__stream.html#a441263e19be4383223884fde8838f736"> 119</a></span>&#160; uvgrtp::frame::rtp_frame *<a class="code" href="classuvgrtp_1_1media__stream.html#a441263e19be4383223884fde8838f736">pull_frame</a>(<span class="keywordtype">size_t</span> timeout);</div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; </div>
<div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27"> 130</a></span>&#160; rtp_error_t <a class="code" href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27">install_receive_hook</a>(<span class="keywordtype">void</span> *arg, <span class="keywordtype">void</span> (*hook)(<span class="keywordtype">void</span> *, uvgrtp::frame::rtp_frame *));</div>
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>&#160; </div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; <span class="comment">/* If system call dispatcher is enabled and calling application has special requirements</span></div>
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>&#160;<span class="comment"> * for the deallocation of a frame, it may install a deallocation hook which is called</span></div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160;<span class="comment"> * when SCD has processed the frame</span></div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160;<span class="comment"> * Return RTP_OK on success</span></div>
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160;<span class="comment"> * Return RTP_INVALID_VALUE if &quot;hook&quot; is nullptr */</span></div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; rtp_error_t install_deallocation_hook(<span class="keywordtype">void</span> (*hook)(<span class="keywordtype">void</span> *));</div>
<div class="line"><a name="l00139"></a><span class="lineno"><a class="line" href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27"> 139</a></span>&#160; rtp_error_t <a class="code" href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27">install_receive_hook</a>(<span class="keywordtype">void</span> *arg, <span class="keywordtype">void</span> (*hook)(<span class="keywordtype">void</span> *, uvgrtp::frame::rtp_frame *));</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; </div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160; <span class="comment">/* If needed, a notification hook can be installed to uvgRTP that can be used as</span></div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160;<span class="comment"> * an information side channel to the internal state of the library.</span></div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160;<span class="comment"> * When uvgRTP encouters a situation it doesn&#39;t know how to react to,</span></div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160;<span class="comment"> * it calls the notify hook with certain notify reason number (src/util.hh).</span></div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160;<span class="comment"> * Upon receiving a notification, application may ignore it or act on it somehow</span></div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160;<span class="comment"> * Currently only one notification type is supported and only receiver uses notifications</span></div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160;<span class="comment"> * &quot;arg&quot; is optional argument that is passed to hook when it is called. It may be nullptr</span></div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160;<span class="comment"> * Return RTP_OK on success</span></div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160;<span class="comment"> * Return RTP_INVALID_VALUE if &quot;hook&quot; is nullptr */</span></div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>&#160; rtp_error_t install_notify_hook(<span class="keywordtype">void</span> *arg, <span class="keywordtype">void</span> (*hook)(<span class="keywordtype">void</span> *, <span class="keywordtype">int</span>));</div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160; </div>
<div class="line"><a name="l00167"></a><span class="lineno"><a class="line" href="classuvgrtp_1_1media__stream.html#addf1cde9cb8c4e4af3160ce24c4288a5"> 167</a></span>&#160; rtp_error_t <a class="code" href="classuvgrtp_1_1media__stream.html#addf1cde9cb8c4e4af3160ce24c4288a5">configure_ctx</a>(<span class="keywordtype">int</span> flag, ssize_t value);</div>
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; </div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; <span class="comment">/* Setter and getter for media-specific config that can be used f.ex with Opus */</span></div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; <span class="keywordtype">void</span> set_media_config(<span class="keywordtype">void</span> *config);</div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; <span class="keywordtype">void</span> *get_media_config();</div>
<div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160; </div>
<div class="line"><a name="l00174"></a><span class="lineno"> 174</span>&#160; <span class="comment">/* Get unique key of the media stream</span></div>
<div class="line"><a name="l00175"></a><span class="lineno"> 175</span>&#160;<span class="comment"> * Used by session to index media streams */</span></div>
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>&#160; uint32_t get_key();</div>
<div class="line"><a name="l00178"></a><span class="lineno"> 178</span>&#160; </div>
<div class="line"><a name="l00191"></a><span class="lineno"><a class="line" href="classuvgrtp_1_1media__stream.html#a1134ff0271ad54bf1e07feed422118c2"> 191</a></span>&#160; <a class="code" href="classuvgrtp_1_1rtcp.html">uvgrtp::rtcp</a> *<a class="code" href="classuvgrtp_1_1media__stream.html#a1134ff0271ad54bf1e07feed422118c2">get_rtcp</a>();</div>
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span>&#160; </div>
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span>&#160; <span class="keyword">private</span>:</div>
<div class="line"><a name="l00194"></a><span class="lineno"> 194</span>&#160; <span class="comment">/* Initialize the connection by initializing the socket</span></div>
<div class="line"><a name="l00195"></a><span class="lineno"> 195</span>&#160;<span class="comment"> * and binding ourselves to specified interface and creating</span></div>
<div class="line"><a name="l00196"></a><span class="lineno"> 196</span>&#160;<span class="comment"> * an outgoing address */</span></div>
<div class="line"><a name="l00197"></a><span class="lineno"> 197</span>&#160; rtp_error_t init_connection();</div>
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>&#160; </div>
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>&#160; uint32_t key_;</div>
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160; </div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; uvgrtp::srtp *srtp_;</div>
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; uvgrtp::srtcp *srtcp_;</div>
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; uvgrtp::socket *socket_;</div>
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160; uvgrtp::rtp *rtp_;</div>
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160; <a class="code" href="classuvgrtp_1_1rtcp.html">uvgrtp::rtcp</a> *rtcp_;</div>
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160; </div>
<div class="line"><a name="l00207"></a><span class="lineno"> 207</span>&#160; sockaddr_in addr_out_;</div>
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160; std::string addr_;</div>
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>&#160; std::string laddr_;</div>
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>&#160; <span class="keywordtype">int</span> src_port_;</div>
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160; <span class="keywordtype">int</span> dst_port_;</div>
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160; rtp_format_t fmt_;</div>
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>&#160; <span class="keywordtype">int</span> flags_;</div>
<div class="line"><a name="l00214"></a><span class="lineno"> 214</span>&#160; </div>
<div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160; <span class="comment">/* Media context config (SCD etc.) */</span></div>
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160; rtp_ctx_conf_t ctx_config_;</div>
<div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160; </div>
<div class="line"><a name="l00218"></a><span class="lineno"> 218</span>&#160; <span class="comment">/* Media config f.ex. for Opus */</span></div>
<div class="line"><a name="l00219"></a><span class="lineno"> 219</span>&#160; <span class="keywordtype">void</span> *media_config_;</div>
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>&#160; </div>
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>&#160; <span class="comment">/* Has the media stream been initialized */</span></div>
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>&#160; <span class="keywordtype">bool</span> initialized_;</div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; <span class="comment">/* If system call dispatcher is enabled and calling application has special requirements</span></div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160;<span class="comment"> * for the deallocation of a frame, it may install a deallocation hook which is called</span></div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160;<span class="comment"> * when SCD has processed the frame</span></div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160;<span class="comment"> * Return RTP_OK on success</span></div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160;<span class="comment"> * Return RTP_INVALID_VALUE if &quot;hook&quot; is nullptr */</span></div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; rtp_error_t install_deallocation_hook(<span class="keywordtype">void</span> (*hook)(<span class="keywordtype">void</span> *));</div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160; </div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160; <span class="comment">/* If needed, a notification hook can be installed to uvgRTP that can be used as</span></div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160;<span class="comment"> * an information side channel to the internal state of the library.</span></div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160;<span class="comment"> * When uvgRTP encouters a situation it doesn&#39;t know how to react to,</span></div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>&#160;<span class="comment"> * it calls the notify hook with certain notify reason number (src/util.hh).</span></div>
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span>&#160;<span class="comment"> * Upon receiving a notification, application may ignore it or act on it somehow</span></div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>&#160;<span class="comment"> * Currently only one notification type is supported and only receiver uses notifications</span></div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>&#160;<span class="comment"> * &quot;arg&quot; is optional argument that is passed to hook when it is called. It may be nullptr</span></div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160;<span class="comment"> * Return RTP_OK on success</span></div>
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span>&#160;<span class="comment"> * Return RTP_INVALID_VALUE if &quot;hook&quot; is nullptr */</span></div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160; rtp_error_t install_notify_hook(<span class="keywordtype">void</span> *arg, <span class="keywordtype">void</span> (*hook)(<span class="keywordtype">void</span> *, <span class="keywordtype">int</span>));</div>
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span>&#160; </div>
<div class="line"><a name="l00176"></a><span class="lineno"><a class="line" href="classuvgrtp_1_1media__stream.html#addf1cde9cb8c4e4af3160ce24c4288a5"> 176</a></span>&#160; rtp_error_t <a class="code" href="classuvgrtp_1_1media__stream.html#addf1cde9cb8c4e4af3160ce24c4288a5">configure_ctx</a>(<span class="keywordtype">int</span> flag, ssize_t value);</div>
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>&#160; </div>
<div class="line"><a name="l00179"></a><span class="lineno"> 179</span>&#160; <span class="comment">/* Setter and getter for media-specific config that can be used f.ex with Opus */</span></div>
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span>&#160; <span class="keywordtype">void</span> set_media_config(<span class="keywordtype">void</span> *config);</div>
<div class="line"><a name="l00181"></a><span class="lineno"> 181</span>&#160; <span class="keywordtype">void</span> *get_media_config();</div>
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span>&#160; </div>
<div class="line"><a name="l00183"></a><span class="lineno"> 183</span>&#160; <span class="comment">/* Get unique key of the media stream</span></div>
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span>&#160;<span class="comment"> * Used by session to index media streams */</span></div>
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span>&#160; uint32_t get_key();</div>
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span>&#160; </div>
<div class="line"><a name="l00200"></a><span class="lineno"><a class="line" href="classuvgrtp_1_1media__stream.html#a1134ff0271ad54bf1e07feed422118c2"> 200</a></span>&#160; <a class="code" href="classuvgrtp_1_1rtcp.html">uvgrtp::rtcp</a> *<a class="code" href="classuvgrtp_1_1media__stream.html#a1134ff0271ad54bf1e07feed422118c2">get_rtcp</a>();</div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; </div>
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; <span class="keyword">private</span>:</div>
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; <span class="comment">/* Initialize the connection by initializing the socket</span></div>
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160;<span class="comment"> * and binding ourselves to specified interface and creating</span></div>
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160;<span class="comment"> * an outgoing address */</span></div>
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160; rtp_error_t init_connection();</div>
<div class="line"><a name="l00207"></a><span class="lineno"> 207</span>&#160; </div>
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160; uint32_t key_;</div>
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>&#160; </div>
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>&#160; uvgrtp::srtp *srtp_;</div>
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160; uvgrtp::srtcp *srtcp_;</div>
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160; uvgrtp::socket *socket_;</div>
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>&#160; uvgrtp::rtp *rtp_;</div>
<div class="line"><a name="l00214"></a><span class="lineno"> 214</span>&#160; <a class="code" href="classuvgrtp_1_1rtcp.html">uvgrtp::rtcp</a> *rtcp_;</div>
<div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160; </div>
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160; sockaddr_in addr_out_;</div>
<div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160; std::string addr_;</div>
<div class="line"><a name="l00218"></a><span class="lineno"> 218</span>&#160; std::string laddr_;</div>
<div class="line"><a name="l00219"></a><span class="lineno"> 219</span>&#160; <span class="keywordtype">int</span> src_port_;</div>
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>&#160; <span class="keywordtype">int</span> dst_port_;</div>
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>&#160; rtp_format_t fmt_;</div>
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>&#160; <span class="keywordtype">int</span> flags_;</div>
<div class="line"><a name="l00223"></a><span class="lineno"> 223</span>&#160; </div>
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span>&#160; <span class="comment">/* Primary handler keys for the RTP packet dispatcher */</span></div>
<div class="line"><a name="l00225"></a><span class="lineno"> 225</span>&#160; uint32_t rtp_handler_key_;</div>
<div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160; uint32_t zrtp_handler_key_;</div>
<div class="line"><a name="l00227"></a><span class="lineno"> 227</span>&#160; </div>
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>&#160; <span class="comment">/* RTP packet dispatcher for the receiver */</span></div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160; uvgrtp::pkt_dispatcher *pkt_dispatcher_;</div>
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>&#160; std::thread *dispatcher_thread_;</div>
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span>&#160; </div>
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>&#160; <span class="comment">/* Media object associated with this media stream. */</span></div>
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160; uvgrtp::formats::media *media_;</div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>&#160; </div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160; <span class="comment">/* Thread that keeps the holepunched connection open for unidirectional streams */</span></div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160; uvgrtp::holepuncher *holepuncher_;</div>
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160; };</div>
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>&#160;};</div>
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160; </div>
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160;<span class="keyword">namespace </span>uvg_rtp = uvgrtp;</div>
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span>&#160; <span class="comment">/* Media context config (SCD etc.) */</span></div>
<div class="line"><a name="l00225"></a><span class="lineno"> 225</span>&#160; rtp_ctx_conf_t ctx_config_;</div>
<div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160; </div>
<div class="line"><a name="l00227"></a><span class="lineno"> 227</span>&#160; <span class="comment">/* Media config f.ex. for Opus */</span></div>
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>&#160; <span class="keywordtype">void</span> *media_config_;</div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160; </div>
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>&#160; <span class="comment">/* Has the media stream been initialized */</span></div>
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span>&#160; <span class="keywordtype">bool</span> initialized_;</div>
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>&#160; </div>
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160; <span class="comment">/* Primary handler keys for the RTP packet dispatcher */</span></div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>&#160; uint32_t rtp_handler_key_;</div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160; uint32_t zrtp_handler_key_;</div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160; </div>
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160; <span class="comment">/* RTP packet dispatcher for the receiver */</span></div>
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>&#160; uvgrtp::pkt_dispatcher *pkt_dispatcher_;</div>
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160; std::thread *dispatcher_thread_;</div>
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160; </div>
<div class="line"><a name="l00241"></a><span class="lineno"> 241</span>&#160; <span class="comment">/* Media object associated with this media stream. */</span></div>
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span>&#160; uvgrtp::formats::media *media_;</div>
<div class="line"><a name="l00243"></a><span class="lineno"> 243</span>&#160; </div>
<div class="line"><a name="l00244"></a><span class="lineno"> 244</span>&#160; <span class="comment">/* Thread that keeps the holepunched connection open for unidirectional streams */</span></div>
<div class="line"><a name="l00245"></a><span class="lineno"> 245</span>&#160; uvgrtp::holepuncher *holepuncher_;</div>
<div class="line"><a name="l00246"></a><span class="lineno"> 246</span>&#160; };</div>
<div class="line"><a name="l00247"></a><span class="lineno"> 247</span>&#160;};</div>
<div class="line"><a name="l00248"></a><span class="lineno"> 248</span>&#160; </div>
<div class="line"><a name="l00249"></a><span class="lineno"> 249</span>&#160;<span class="keyword">namespace </span>uvg_rtp = uvgrtp;</div>
<div class="ttc" id="aclassuvgrtp_1_1media__stream_html"><div class="ttname"><a href="classuvgrtp_1_1media__stream.html">uvgrtp::media_stream</a></div><div class="ttdef"><b>Definition:</b> media_stream.hh:18</div></div>
<div class="ttc" id="aclassuvgrtp_1_1media__stream_html_a1134ff0271ad54bf1e07feed422118c2"><div class="ttname"><a href="classuvgrtp_1_1media__stream.html#a1134ff0271ad54bf1e07feed422118c2">uvgrtp::media_stream::get_rtcp</a></div><div class="ttdeci">uvgrtp::rtcp * get_rtcp()</div><div class="ttdoc">Get pointer to the RTCP object of the media stream.</div></div>
<div class="ttc" id="aclassuvgrtp_1_1media__stream_html_a441263e19be4383223884fde8838f736"><div class="ttname"><a href="classuvgrtp_1_1media__stream.html#a441263e19be4383223884fde8838f736">uvgrtp::media_stream::pull_frame</a></div><div class="ttdeci">uvgrtp::frame::rtp_frame * pull_frame(size_t timeout)</div><div class="ttdoc">Poll a frame for a specified time from the media stream object.</div></div>
<div class="ttc" id="aclassuvgrtp_1_1media__stream_html_a74a558b23866976e52c5903996544a27"><div class="ttname"><a href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27">uvgrtp::media_stream::install_receive_hook</a></div><div class="ttdeci">rtp_error_t install_receive_hook(void *arg, void(*hook)(void *, uvgrtp::frame::rtp_frame *))</div></div>
<div class="ttc" id="aclassuvgrtp_1_1media__stream_html_a74a558b23866976e52c5903996544a27"><div class="ttname"><a href="classuvgrtp_1_1media__stream.html#a74a558b23866976e52c5903996544a27">uvgrtp::media_stream::install_receive_hook</a></div><div class="ttdeci">rtp_error_t install_receive_hook(void *arg, void(*hook)(void *, uvgrtp::frame::rtp_frame *))</div><div class="ttdoc">Asynchronous way of getting frames.</div></div>
<div class="ttc" id="aclassuvgrtp_1_1media__stream_html_ab2b7507d5b2c76bef74c9bceec07ba18"><div class="ttname"><a href="classuvgrtp_1_1media__stream.html#ab2b7507d5b2c76bef74c9bceec07ba18">uvgrtp::media_stream::push_frame</a></div><div class="ttdeci">rtp_error_t push_frame(uint8_t *data, size_t data_len, int flags)</div></div>
<div class="ttc" id="aclassuvgrtp_1_1media__stream_html_addf1cde9cb8c4e4af3160ce24c4288a5"><div class="ttname"><a href="classuvgrtp_1_1media__stream.html#addf1cde9cb8c4e4af3160ce24c4288a5">uvgrtp::media_stream::configure_ctx</a></div><div class="ttdeci">rtp_error_t configure_ctx(int flag, ssize_t value)</div><div class="ttdoc">Configure the media stream, see RTP_CTX_CONFIGURATION_FLAGS for more details.</div></div>
<div class="ttc" id="aclassuvgrtp_1_1media__stream_html_ae2fe9e8d9b67e25f103a78a25417149f"><div class="ttname"><a href="classuvgrtp_1_1media__stream.html#ae2fe9e8d9b67e25f103a78a25417149f">uvgrtp::media_stream::pull_frame</a></div><div class="ttdeci">uvgrtp::frame::rtp_frame * pull_frame()</div><div class="ttdoc">Poll a frame indefinetily from the media stream object.</div></div>

View File

@ -118,15 +118,24 @@ namespace uvgrtp {
* Return pointer to RTP frame on success */
uvgrtp::frame::rtp_frame *pull_frame(size_t timeout);
/** Alternative to pull_frame(). The provided hook is called when a frame is received.
/**
* \brief Asynchronous way of getting frames
*
* "arg" is optional argument that is passed to hook when it is called. It may be nullptr
* \details Receive hook is an alternative to polling frames using uvgrtp::media_stream::pull_frame().
* Instead of application asking from uvgRTP if there are any new frames available, uvgRTP will notify
* the application when a frame has been received
*
* NOTE: Hook should not be used to process the frame but it should be a place where the
* frame handout happens from uvgRTP to application
* The hook should not be used for media processing as it will block the receiver from
* reading more frames. Instead, it should only be used as an interface between uvgRTP and
* the calling application where the frame hand-off happens.
*
* Return RTP_OK on success
* Return RTP_INVALID_VALUE if "hook" is nullptr */
* \param arg Optional argument that is passed to the hook when it is called, can be set to nullptr
* \param hook Function pointer to the receive hook that uvgRTP should call
*
* \return RTP error code
*
* \retval RTP_OK On success
* \retval RTP_INVALID_VALUE If hook is nullptr */
rtp_error_t install_receive_hook(void *arg, void (*hook)(void *, uvgrtp::frame::rtp_frame *));
/// \cond DO_NOT_DOCUMENT