<divclass="line"><aid="l00022"name="l00022"></a><spanclass="lineno"> 22</span><spanclass="keyword">typedef</span> std::vector<std::pair<size_t, uint8_t*>> buf_vec; <spanclass="comment">// also defined in socket.hh</span></div>
<divclass="line"><aid="l00032"name="l00032"></a><spanclass="lineno"> 32</span> uint32_t sent_pkts = 0; <spanclass="comment">/* Number of sent RTP packets */</span></div>
<divclass="line"><aid="l00033"name="l00033"></a><spanclass="lineno"> 33</span> uint32_t sent_bytes = 0; <spanclass="comment">/* Number of sent bytes excluding RTP Header */</span></div>
<divclass="line"><aid="l00034"name="l00034"></a><spanclass="lineno"> 34</span><spanclass="keywordtype">bool</span> sent_rtp_packet = <spanclass="keyword">false</span>; <spanclass="comment">// since last report</span></div>
<divclass="line"><aid="l00039"name="l00039"></a><spanclass="lineno"> 39</span> uint32_t received_pkts = 0; <spanclass="comment">/* Number of packets received */</span></div>
<divclass="line"><aid="l00040"name="l00040"></a><spanclass="lineno"> 40</span> uint32_t dropped_pkts = 0; <spanclass="comment">/* Number of dropped RTP packets */</span></div>
<divclass="line"><aid="l00041"name="l00041"></a><spanclass="lineno"> 41</span> uint32_t received_bytes = 0; <spanclass="comment">/* Number of bytes received excluding RTP Header */</span></div>
<divclass="line"><aid="l00042"name="l00042"></a><spanclass="lineno"> 42</span><spanclass="keywordtype">bool</span> received_rtp_packet = <spanclass="keyword">false</span>; <spanclass="comment">// since last report</span></div>
<divclass="line"><aid="l00044"name="l00044"></a><spanclass="lineno"> 44</span><spanclass="keywordtype">double</span> jitter = 0; <spanclass="comment">/* The estimation of jitter (see RFC 3550 A.8) */</span></div>
<divclass="line"><aid="l00048"name="l00048"></a><spanclass="lineno"> 48</span><spanclass="comment">/* Receiver clock related stuff */</span></div>
<divclass="line"><aid="l00049"name="l00049"></a><spanclass="lineno"> 49</span> uint64_t initial_ntp = 0; <spanclass="comment">/* Wallclock reading when the first RTP packet was received */</span></div>
<divclass="line"><aid="l00050"name="l00050"></a><spanclass="lineno"> 50</span> uint32_t initial_rtp = 0; <spanclass="comment">/* RTP timestamp of the first RTP packet received */</span></div>
<divclass="line"><aid="l00051"name="l00051"></a><spanclass="lineno"> 51</span> uint32_t clock_rate = 0; <spanclass="comment">/* Rate of the clock (used for jitter calculations) */</span></div>
<divclass="line"><aid="l00053"name="l00053"></a><spanclass="lineno"> 53</span> uint32_t lsr = 0; <spanclass="comment">/* Middle 32 bits of the 64-bit NTP timestamp of previous SR */</span></div>
<divclass="line"><aid="l00054"name="l00054"></a><spanclass="lineno"> 54</span> uvgrtp::clock::hrc::hrc_t sr_ts; <spanclass="comment">/* When the last SR was received (used to calculate delay) */</span></div>
<divclass="line"><aid="l00056"name="l00056"></a><spanclass="lineno"> 56</span> uint16_t max_seq = 0; <spanclass="comment">/* Highest sequence number received */</span></div>
<divclass="line"><aid="l00057"name="l00057"></a><spanclass="lineno"> 57</span> uint32_t base_seq = 0; <spanclass="comment">/* First sequence number received */</span></div>
<divclass="line"><aid="l00067"name="l00067"></a><spanclass="lineno"> 67</span> uint32_t probation = 0; <spanclass="comment">/* has the participant been fully accepted to the session */</span></div>
<divclass="line"><aid="l00068"name="l00068"></a><spanclass="lineno"> 68</span><spanclass="keywordtype">int</span> role = 0; <spanclass="comment">/* is the participant a sender or a receiver */</span></div>
<divclass="line"><aid="l00070"name="l00070"></a><spanclass="lineno"> 70</span><spanclass="comment">/* Save the latest RTCP packets received from this participant</span></div>
<divclass="line"><aid="l00071"name="l00071"></a><spanclass="lineno"> 71</span><spanclass="comment"> * Users can query these packets using the SSRC of participant */</span></div>
<divclass="line"><aid="l00117"name="l00117"></a><spanclass="lineno"> 117</span><spanclass="comment"> * return RTP_OK on success and RTP_MEMORY_ERROR if the allocation fails */</span></div>
<divclass="line"><aid="l00120"name="l00120"></a><spanclass="lineno"> 120</span><spanclass="comment">/* End the RTCP session and send RTCP BYE to all participants</span></div>
<divclass="line"><aid="l00125"name="l00125"></a><spanclass="lineno"> 125</span><spanclass="comment">/* Generate either RTCP Sender or Receiver report and sent it to all participants</span></div>
<divclass="line"><aid="l00126"name="l00126"></a><spanclass="lineno"> 126</span><spanclass="comment"> * Return RTP_OK on success and RTP_ERROR on error */</span></div>
<divclass="line"><aid="l00129"name="l00129"></a><spanclass="lineno"> 129</span><spanclass="comment">/* Handle incoming RTCP packet (first make sure it's a valid RTCP packet)</span></div>
<divclass="line"><aid="l00130"name="l00130"></a><spanclass="lineno"> 130</span><spanclass="comment"> * This function will call one of the above functions internally</span></div>
<divclass="line"><aid="l00132"name="l00132"></a><spanclass="lineno"> 132</span><spanclass="comment"> * Return RTP_OK on success and RTP_ERROR on error */</span></div>
<divclass="line"><aid="l00136"name="l00136"></a><spanclass="lineno"> 136</span><spanclass="comment">/* Send "frame" to all participants</span></div>
<divclass="line"><aid="l00138"name="l00138"></a><spanclass="lineno"> 138</span><spanclass="comment"> * These routines will convert all necessary fields to network byte order</span></div>
<divclass="line"><aid="l00140"name="l00140"></a><spanclass="lineno"> 140</span><spanclass="comment"> * Return RTP_OK on success</span></div>
<divclass="line"><aid="l00141"name="l00141"></a><spanclass="lineno"> 141</span><spanclass="comment"> * Return RTP_INVALID_VALUE if "frame" is in some way invalid</span></div>
<divclass="line"><aid="l00142"name="l00142"></a><spanclass="lineno"> 142</span><spanclass="comment"> * Return RTP_SEND_ERROR if sending "frame" did not succeed (see socket.hh for details) */</span></div>
<divclass="line"><aid="l00186"name="l00186"></a><spanclass="lineno"> 186</span><spanclass="comment">/* Return the latest RTCP packet received from participant of "ssrc"</span></div>
<divclass="line"><aid="l00187"name="l00187"></a><spanclass="lineno"> 187</span><spanclass="comment"> * Return nullptr if we haven't received this kind of packet or if "ssrc" doesn't exist</span></div>
<divclass="line"><aid="l00189"name="l00189"></a><spanclass="lineno"> 189</span><spanclass="comment"> * NOTE: Caller is responsible for deallocating the memory */</span></div>
<divclass="line"><aid="l00195"name="l00195"></a><spanclass="lineno"> 195</span><spanclass="comment">/* Return a reference to vector that contains the sockets of all participants */</span></div>
<divclass="line"><aid="l00198"name="l00198"></a><spanclass="lineno"> 198</span><spanclass="comment">/* Somebody joined the multicast group the owner of this RTCP instance is part of</span></div>
<divclass="line"><aid="l00199"name="l00199"></a><spanclass="lineno"> 199</span><spanclass="comment"> * Add it to RTCP participant list so we can start listening for reports</span></div>
<divclass="line"><aid="l00201"name="l00201"></a><spanclass="lineno"> 201</span><spanclass="comment"> * "clock_rate" tells how much the RTP timestamp advances, this information is needed</span></div>
<divclass="line"><aid="l00202"name="l00202"></a><spanclass="lineno"> 202</span><spanclass="comment"> * to calculate the interarrival jitter correctly. It has nothing do with our clock rate,</span></div>
<divclass="line"><aid="l00203"name="l00203"></a><spanclass="lineno"> 203</span><spanclass="comment"> * (or whether we're even sending anything)</span></div>
<divclass="line"><aid="l00205"name="l00205"></a><spanclass="lineno"> 205</span><spanclass="comment"> * Return RTP_OK on success and RTP_ERROR on error */</span></div>
<divclass="line"><aid="l00208"name="l00208"></a><spanclass="lineno"> 208</span><spanclass="comment">/* Functions for updating various RTP sender statistics */</span></div>
<divclass="line"><aid="l00211"name="l00211"></a><spanclass="lineno"> 211</span><spanclass="comment">/* If we've detected that our SSRC has collided with someone else's SSRC, we need to</span></div>
<divclass="line"><aid="l00212"name="l00212"></a><spanclass="lineno"> 212</span><spanclass="comment"> * generate new random SSRC and reinitialize our own RTCP state.</span></div>
<divclass="line"><aid="l00213"name="l00213"></a><spanclass="lineno"> 213</span><spanclass="comment"> * RTCP object still has the participants of "last session", we can use their SSRCs</span></div>
<divclass="line"><aid="l00214"name="l00214"></a><spanclass="lineno"> 214</span><spanclass="comment"> * to detected new collision</span></div>
<divclass="line"><aid="l00216"name="l00216"></a><spanclass="lineno"> 216</span><spanclass="comment"> * Return RTP_OK if reinitialization succeeded</span></div>
<divclass="line"><aid="l00217"name="l00217"></a><spanclass="lineno"> 217</span><spanclass="comment"> * Return RTP_SSRC_COLLISION if our new SSRC has collided and we need to generate new SSRC */</span></div>
<divclass="line"><aid="l00223"name="l00223"></a><spanclass="lineno"> 223</span><spanclass="comment">/* Getter for interval_ms_, which is calculated by set_session_bandwidth */</span></div>
<divclass="line"><aid="l00228"name="l00228"></a><spanclass="lineno"> 228</span><spanclass="comment">/* Return SSRCs of all participants */</span></div>
<divclass="line"><aid="l00248"name="l00248"></a><spanclass="lineno"> 248</span><spanclass="comment">/* Alternate way to get RTCP packets is to install a hook for them. So instead of</span></div>
<divclass="line"><aid="l00249"name="l00249"></a><spanclass="lineno"> 249</span><spanclass="comment"> * polling an RTCP packet, user can install a function that is called when</span></div>
<divclass="line"><aid="l00250"name="l00250"></a><spanclass="lineno"> 250</span><spanclass="comment"> * a specific RTCP packet is received. */</span></div>
<divclass="line"><aid="l00349"name="l00349"></a><spanclass="lineno"> 349</span><spanclass="comment">// These have been replaced by functions with unique_ptr in them</span></div>
<divclass="line"><aid="l00375"name="l00375"></a><spanclass="lineno"> 375</span><spanclass="comment">// the length field is the rtcp packet size measured in 32-bit words - 1</span></div>
<divclass="line"><aid="l00390"name="l00390"></a><spanclass="lineno"> 390</span><spanclass="comment">/* read the header values from rtcp packet */</span></div>
<divclass="line"><aid="l00398"name="l00398"></a><spanclass="lineno"> 398</span><spanclass="comment">/* Handle different kinds of incoming rtcp packets. The read header is passed to functions</span></div>
<divclass="line"><aid="l00399"name="l00399"></a><spanclass="lineno"> 399</span><spanclass="comment"> which read rest of the frame type specific data.</span></div>
<divclass="line"><aid="l00400"name="l00400"></a><spanclass="lineno"> 400</span><spanclass="comment"> * Return RTP_OK on success and RTP_ERROR on error */</span></div>
<divclass="line"><aid="l00414"name="l00414"></a><spanclass="lineno"> 414</span><spanclass="comment">/* when we start the RTCP instance, we don't know what the SSRC of the remote is</span></div>
<divclass="line"><aid="l00415"name="l00415"></a><spanclass="lineno"> 415</span><spanclass="comment"> * when an RTP packet is received, we must check if we've already received a packet</span></div>
<divclass="line"><aid="l00416"name="l00416"></a><spanclass="lineno"> 416</span><spanclass="comment"> * from this sender and if not, create new entry to receiver_stats_ map */</span></div>
<divclass="line"><aid="l00419"name="l00419"></a><spanclass="lineno"> 419</span><spanclass="comment">/* When we receive an RTP or RTCP packet, we need to check the source address and see if it's</span></div>
<divclass="line"><aid="l00420"name="l00420"></a><spanclass="lineno"> 420</span><spanclass="comment"> * the same address where we've received packets before.</span></div>
<divclass="line"><aid="l00422"name="l00422"></a><spanclass="lineno"> 422</span><spanclass="comment"> * If the address is new, it means we have detected an SSRC collision and the paket should</span></div>
<divclass="line"><aid="l00423"name="l00423"></a><spanclass="lineno"> 423</span><spanclass="comment"> * be dropped We also need to check whether this SSRC matches with our own SSRC and if it does</span></div>
<divclass="line"><aid="l00424"name="l00424"></a><spanclass="lineno"> 424</span><spanclass="comment"> * we need to send RTCP BYE and rejoin to the session */</span></div>
<divclass="line"><aid="l00427"name="l00427"></a><spanclass="lineno"> 427</span><spanclass="comment">/* Move participant from initial_peers_ to participants_ */</span></div>
<divclass="line"><aid="l00430"name="l00430"></a><spanclass="lineno"> 430</span><spanclass="comment">/* We've got a message from new source (the SSRC of the frame is not known to us)</span></div>
<divclass="line"><aid="l00431"name="l00431"></a><spanclass="lineno"> 431</span><spanclass="comment"> * Initialize statistics for the peer and move it to participants_ */</span></div>
<divclass="line"><aid="l00434"name="l00434"></a><spanclass="lineno"> 434</span><spanclass="comment">/* Initialize the RTP Sequence related stuff of peer</span></div>
<divclass="line"><aid="l00435"name="l00435"></a><spanclass="lineno"> 435</span><spanclass="comment"> * This function assumes that the peer already exists in the participants_ map */</span></div>
<divclass="line"><aid="l00438"name="l00438"></a><spanclass="lineno"> 438</span><spanclass="comment">/* Update the SSRC's sequence related data in participants_ map</span></div>
<divclass="line"><aid="l00440"name="l00440"></a><spanclass="lineno"> 440</span><spanclass="comment"> * Return RTP_OK if the received packet was OK</span></div>
<divclass="line"><aid="l00441"name="l00441"></a><spanclass="lineno"> 441</span><spanclass="comment"> * Return RTP_GENERIC_ERROR if it wasn't and</span></div>
<divclass="line"><aid="l00442"name="l00442"></a><spanclass="lineno"> 442</span><spanclass="comment"> * packet-related statistics should not be updated */</span></div>
<divclass="line"><aid="l00447"name="l00447"></a><spanclass="lineno"> 447</span><spanclass="comment"> * "pkt_size" tells how much rtcp_byte_count_</span></div>
<divclass="line"><aid="l00448"name="l00448"></a><spanclass="lineno"> 448</span><spanclass="comment"> * should be increased before calculating the new average */</span></div>
<divclass="line"><aid="l00451"name="l00451"></a><spanclass="lineno"> 451</span><spanclass="comment">/* Because struct statistics contains uvgRTP clock object we cannot</span></div>
<divclass="line"><aid="l00452"name="l00452"></a><spanclass="lineno"> 452</span><spanclass="comment"> * zero it out without compiler complaining about it so all the fields</span></div>
<divclass="line"><aid="l00453"name="l00453"></a><spanclass="lineno"> 453</span><spanclass="comment"> * must be set to zero manually */</span></div>
<divclass="line"><aid="l00471"name="l00471"></a><spanclass="lineno"> 471</span><spanclass="comment">/* are we a sender (and possible a receiver) or just a receiver */</span></div>
<divclass="line"><aid="l00475"name="l00475"></a><spanclass="lineno"> 475</span><spanclass="comment">// TODO: Check these, they don't seem to be used</span></div>
<divclass="line"><aid="l00476"name="l00476"></a><spanclass="lineno"> 476</span><spanclass="keywordtype">size_t</span> tp_; <spanclass="comment">/* the last time an RTCP packet was transmitted */</span></div>
<divclass="line"><aid="l00477"name="l00477"></a><spanclass="lineno"> 477</span><spanclass="keywordtype">size_t</span> tc_; <spanclass="comment">/* the current time */</span></div>
<divclass="line"><aid="l00478"name="l00478"></a><spanclass="lineno"> 478</span><spanclass="keywordtype">size_t</span> tn_; <spanclass="comment">/* the next scheduled transmission time of an RTCP packet */</span></div>
<divclass="line"><aid="l00479"name="l00479"></a><spanclass="lineno"> 479</span><spanclass="keywordtype">size_t</span> pmembers_; <spanclass="comment">/* the estimated number of session members at the time tn was last recomputed */</span></div>
<divclass="line"><aid="l00480"name="l00480"></a><spanclass="lineno"> 480</span><spanclass="keywordtype">size_t</span> members_; <spanclass="comment">/* the most current estimate for the number of session members */</span></div>
<divclass="line"><aid="l00481"name="l00481"></a><spanclass="lineno"> 481</span><spanclass="keywordtype">size_t</span> senders_; <spanclass="comment">/* the most current estimate for the number of senders in the session */</span></div>
<divclass="line"><aid="l00483"name="l00483"></a><spanclass="lineno"> 483</span><spanclass="comment">/* The target RTCP bandwidth, i.e., the total bandwidth</span></div>
<divclass="line"><aid="l00484"name="l00484"></a><spanclass="lineno"> 484</span><spanclass="comment"> * that will be used for RTCP packets by all members of this session,</span></div>
<divclass="line"><aid="l00485"name="l00485"></a><spanclass="lineno"> 485</span><spanclass="comment"> * in octets per second. This will be a specified fraction of the</span></div>
<divclass="line"><aid="l00486"name="l00486"></a><spanclass="lineno"> 486</span><spanclass="comment"> * "session bandwidth" parameter supplied to the application at startup. */</span></div>
<divclass="line"><aid="l00487"name="l00487"></a><spanclass="lineno"> 487</span><spanclass="comment">// TODO: Not used anywhere at the moment</span></div>
<divclass="line"><aid="l00490"name="l00490"></a><spanclass="lineno"> 490</span><spanclass="comment">/* Flag that is true if the application has sent data since</span></div>
<divclass="line"><aid="l00491"name="l00491"></a><spanclass="lineno"> 491</span><spanclass="comment"> * the 2nd previous RTCP report was transmitted. */</span></div>
<divclass="line"><aid="l00492"name="l00492"></a><spanclass="lineno"> 492</span><spanclass="comment">// TODO: Only set, never read</span></div>
<divclass="line"><aid="l00495"name="l00495"></a><spanclass="lineno"> 495</span><spanclass="comment">/* The average compound RTCP packet size, in octets,</span></div>
<divclass="line"><aid="l00496"name="l00496"></a><spanclass="lineno"> 496</span><spanclass="comment"> * over all RTCP packets sent and received by this participant. The</span></div>
<divclass="line"><aid="l00497"name="l00497"></a><spanclass="lineno"> 497</span><spanclass="comment"> * size includes lower-layer transport and network protocol headers</span></div>
<divclass="line"><aid="l00498"name="l00498"></a><spanclass="lineno"> 498</span><spanclass="comment"> * (e.g., UDP and IP) as explained in Section 6.2 */</span></div>
<divclass="line"><aid="l00499"name="l00499"></a><spanclass="lineno"> 499</span><spanclass="comment">// TODO: Only set, never read</span></div>
<divclass="line"><aid="l00502"name="l00502"></a><spanclass="lineno"> 502</span><spanclass="comment">/* Number of RTCP packets and bytes sent and received by this participant */</span></div>
<divclass="line"><aid="l00503"name="l00503"></a><spanclass="lineno"> 503</span><spanclass="comment">// TODO: Only set, never read</span></div>
<divclass="line"><aid="l00510"name="l00510"></a><spanclass="lineno"> 510</span><spanclass="comment">/* Flag that is true if the application has not yet sent an RTCP packet. */</span></div>
<divclass="line"><aid="l00511"name="l00511"></a><spanclass="lineno"> 511</span><spanclass="comment">// TODO: Only set, never read</span></div>
<divclass="line"><aid="l00520"name="l00520"></a><spanclass="lineno"> 520</span><spanclass="comment">/* Clock rate of the media ie. how fast does the time increase */</span></div>
<divclass="line"><aid="l00523"name="l00523"></a><spanclass="lineno"> 523</span><spanclass="comment">/* The first value of RTP timestamp (aka t = 0) */</span></div>
<divclass="line"><aid="l00527"name="l00527"></a><spanclass="lineno"> 527</span> uint8_t num_receivers_; <spanclass="comment">// maximum is 32 at the moment (5 bits)</span></div>
<divclass="line"><aid="l00529"name="l00529"></a><spanclass="lineno"> 529</span><spanclass="comment">/* statistics for RTCP Sender and Receiver Reports */</span></div>
<divclass="line"><aid="l00532"name="l00532"></a><spanclass="lineno"> 532</span><spanclass="comment">/* If we expect frames from remote but haven't received anything from remote yet,</span></div>
<divclass="line"><aid="l00533"name="l00533"></a><spanclass="lineno"> 533</span><spanclass="comment"> * the participant resides in this vector until he's moved to participants_ */</span></div>
<divclass="line"><aid="l00536"name="l00536"></a><spanclass="lineno"> 536</span><spanclass="comment">/* Vector of sockets the RTCP runner is listening to</span></div>
<divclass="line"><aid="l00538"name="l00538"></a><spanclass="lineno"> 538</span><spanclass="comment"> * The socket are also stored here (in addition to participants_ map) so they're easier</span></div>
<divclass="line"><aid="l00539"name="l00539"></a><spanclass="lineno"> 539</span><spanclass="comment"> * to pass to poll when RTCP runner is listening to incoming packets */</span></div>
<divclass="line"><aid="l00576"name="l00576"></a><spanclass="lineno"> 576</span> std::vector<uint32_t> bye_ssrcs_; <spanclass="comment">// sent once</span></div>
<divclass="line"><aid="l00577"name="l00577"></a><spanclass="lineno"> 577</span> std::map<std::string, std::deque<rtcp_app_packet>> app_packets_; <spanclass="comment">// sent one at a time per name</span></div>
<divclass="ttc"id="aclassuvgrtp_1_1rtcp_html"><divclass="ttname"><ahref="classuvgrtp_1_1rtcp.html">uvgrtp::rtcp</a></div><divclass="ttdoc">RTCP instance handles all incoming and outgoing RTCP traffic, including report generation.</div><divclass="ttdef"><b>Definition:</b><ahref="rtcp_8hh_source.html#l00108">rtcp.hh:108</a></div></div>
<divclass="ttc"id="aclassuvgrtp_1_1rtcp_html_a81198428cc697c0c7cbb2a4191f294d8"><divclass="ttname"><ahref="classuvgrtp_1_1rtcp.html#a81198428cc697c0c7cbb2a4191f294d8">uvgrtp::rtcp::remove_all_hooks</a></div><divclass="ttdeci">rtp_error_t remove_all_hooks()</div><divclass="ttdoc">Remove all installed hooks for RTCP.</div></div>
<divclass="ttc"id="astructuvgrtp_1_1frame_1_1rtcp__header_html"><divclass="ttname"><ahref="structuvgrtp_1_1frame_1_1rtcp__header.html">uvgrtp::frame::rtcp_header</a></div><divclass="ttdoc">Header of for all RTCP packets defined in RFC 3550 section 6</div><divclass="ttdef"><b>Definition:</b><ahref="frame_8hh_source.html#l00074">frame.hh:74</a></div></div>