JRTPLIB 3.5.2 Chinese version-part12

Source: Internet
Author: User

 

3.2.16 RTPPacketBuilder

------------------------------------------------------------------------- Header file: rtppacketbuilder. h

This class can be used to construct RTP data packets, which is more advanced than RTPPacket: it can generate SSRC identifiers, tracking timestamps, serial numbers, and so on. The interface is as follows:

Int Init (size_t maxpacksize)

----- Initialize the builder so that the allowed package size is smaller than maxpack.

Void Destroy ()

----- Clean the builder.

Uint32_t GetPacketCount ()

----- Return the number of packages created with the current SSRC identifier.

Uint32_t GetPayloadOctetCount ()

----- Return the number of load bytes generated by the SSRC identifier.

Int SetMaximumPacketSize (size_t maxpacksize)

----- Set the maximum allowed package size to maxpacksize.

Int AddCSRC (uint32_t csrc)

----- Add an SSRC to the CSRC linked list to be saved in the RTP package.

Int DeleteCSRC (uint32_t csrc)

----- Delete an SSRC from the CSRC table of the RTP package to be saved.

Void merge srclist ()

----- Clear the CSRC linked list.

Int BuildPacket (const void * data, size_t len)

----- Construct a data packet whose load is len, the load type, identifier, timestamp increment, and other values set using the SetDefault function.

Int BuildPacket (const void * data, size_t len, uint8_t pt, bool mark, uint32_t timestampinc)

----- Construct a data packet whose load is len, the load type is pt, the flag is mark, and the timestamp increment after the packet construction is successful is temstamp.

Int BuildPacketEx (const void * data, size_t len, uint16_t hdrextID, const void * hdrextdata, size_t numhdrextwords)

----- Construct a data packet whose load is len, the load type, identifier, timestamp increment, and other values set using the SetDefault function. The data packet also contains an RTP extension header with the identifier hdrextID data as hdrextdata. The length of the extension data header is given by a 32-bit word numhdrextwords.

Int BuildPacketEx (const void * data, size_t len, uint8_t pt, bool mark, uint32_t timestampinc, uint16_t hdrextID, const void * hdrextdata, size_t handle)

----- Construct a data packet whose load is len, the load type is pt, the flag is mark, and the timestamp increment after the packet construction is successful is temstamp. The data packet also contains an RTP extension header with the identifier hdrextID data as hdrextdata. The length of the extension data header is given by a 32-bit word numhdrextwords.

Uint8_t * GetPacket ()

----- Returns the pointer to the RTP data packet built last time.

Size_t GetPacketLength ()

----- Return the length of the last constructed RTP data packet.

Int setdefapaypayloadtype (uint8_t pt)

----- Set the default load type to pt.

Int setdefamark mark (bool m)

----- Set the default flag to m.

Int setdefatimetimestampincrement (uint32_t timestampinc)

----- Set the default timestamp increment to timestampinc.

Int IncrementTimestamp (uint32_t inc)

----- The function adds a timestamp with the given inc. This function is sometimes useful. For example, when a data packet only contains silent data but does not send data, this function should be called to increase the timestamp according to the appropriate amount, in this way, other hosts can play the next packet at the right time.

Int IncrementTimestampDefault ()

----- The function uses the amount specified by SetDefaultTimestampIncrement to increase the timestamp. This function is useful. For example, when a data packet only contains silent data and is not sent, this function should be called to increase the timestamp according to the appropriate amount, in this way, other hosts can play the next packet at the right time.

Uint32_t CreateNewSSRC ()

----- Create a new SSRC in the generated data packet, which will generate a new Timestamp and serial number increment.

Uint32_t CreateNewSSRC (RTPSources & sources)

----- Create a new SSRC in the generated data packet, which generates a new Timestamp and serial number increment. The source table sources is used to ensure that the selected SSRC is not used by other participants.

Uint32_t GetSSRC ()

----- Returns the current SSRC identifier.

Uint32_t GetTimestamp ()

----- Returns the current RTP timestamp.

Uint16_t GetSequenceNumber ()

----- Returns the current serial number.

RTPTime GetPacketTime ()

----- Return the data packet generation time. This does not need to be the time generated by the previous RTP package. If the timestamp increment is 0, the time will not be updated.

Uint32_t GetPacketTimestamp ()

----- Return the RTP timestamp corresponding to the time returned by the previous function.

 

3.2.17 RTCPPacketBuilder

----------------------------------------------------------------------- Header file: rtcppacketbuilder. h

Class RTCPPacketBuilder can be used to construct RTCP Composite data packets. This function is more advanced than RTCPCompoundPacketBuilder: it uses the information of RTPPacketBuilder object and RTPSources object to automatically generate the next Composite data packet to be sent, in addition, the class also provides functions to determine whether SDES items, rather than CNAME items, should be sent. Class interface:

RTCPPacketBuilder (RTPSources & sources, RTPPacketBuilder & rtppackbuilder)

----- Create an RTCPPacketBuilder object and use the information contained in the next RTCP Composite data package determined by the source table sources and RTP data packet builder rtppacketbuiler.

Int Init (size_t maxpacksize, double timestampunit, const void * cname, size_t cnamelen)

----- Use maxpacksize, timestampunit, And the SDES cname item given by the CNAME with the length of cnamelen to initialize the builder. The unit of timestamp is defined as: the number of samples within a period of time divided by the length of the time segment. For 1.0Hz audio, the unit is 8000.0.

Void Destroy ()

----- Clear the builder.

Int SetTimestampUnit (double tsunit)

----- Set the unit of Timestamp to tsunit. The unit of timestamp is defined as: the number of samples within a period of time divided by the length of the time segment. For 1.0Hz audio, the unit is 8000.0.

Int SetMaximumPacketSize (size_t maxpacksize)

----- Set the maximum allowed RTCP composite packet size to maxpacksize.

Int SetPreTransmissionDelay (const RTPTime & delay)

----- The function allows you to notify the RTCP packet builder of the delay between the first sampling packet and the sent packet. When used for interactive multimedia synchronization, the latency is considered to calculate the relationship between the RTP Timestamp and the clock time.

Int BuildNextPacket (RTCPCompoundPacket ** pack)

----- Construct the RTCP composite packet to be sent in the next pack.

Int BuildBYEPacket (RTCPCompoundPacket ** pack, const void * reason, size_t reasonlength, bool usesripossible = true)

----- Construct a BYE data packet with a reasonlength reason that gives the reason for leaving. If usesripossible is set to true, RTCP Composite data packets start with the sender report if allowed; otherwise, the RTCP Composite data packets start with the receiver report.

Void SetNameInterval (int count)

----- After all the sources in the source table have been processed, the class will check whether other SDES items need to be sent. If count is 0 or negative, nothing will happen. If it is positive, after the source in the source table is processed count times, an SDES name item will be added to the end.

Void SetEMailInterval (int count)

----- After all the sources in the source table have been processed, the class will check whether other SDES items need to be sent. If count is 0 or negative, nothing will happen. If it is positive, after the source in the source table is processed count times, an SDES e-mail entry will be added to the backend.

Void SetLocationInterval (int count)

----- After all the sources in the source table have been processed, the class will check whether other SDES items need to be sent. If count is 0 or negative, nothing will happen. If it is positive, after the source in the source table is processed count times, an SDES location item will be added to the end.

Void SetPhoneInterval (int count)

----- After all the sources in the source table have been processed, the class will check whether other SDES items need to be sent. If count is 0 or negative, nothing will happen. If it is positive, after the source in the source table is processed count times, an SDES phone item is added to the end.

Void SetToolInterval (int count)

----- After all the sources in the source table have been processed, the class will check whether other SDES items need to be sent. If count is 0 or negative, nothing will happen. If it is positive, after the source in the source table is processed count times, an SDES tool item will be added to the end.

Void SetNoteInterval (int count)

----- After all the sources in the source table have been processed, the class will check whether other SDES items need to be sent. If count is 0 or negative, nothing will happen. If it is positive, after the source in the source table is processed count times, an SDES note item will be added later.

Int SetLocalName (const void * s, size t len)

----- Set the SDES name of the local participant to len and value to value.

Int SetLocalEMail (const void * s, size t len)

----- Set the sdes e-mai item of the local participant to len and value to value.

Int SetLocalLocation (const void * s, size t len)

----- Set the SDES location item of the local participant to len and value to value.

Int SetLocalPhone (const void * s, size t len)

----- Set the SDES phone item of the local participant to len and value to value.

Int SetLocalTool (const void * s, size t len)

----- Set the SDES tool item of the local participant to len and value to value.

Int SetLocalNote (const void * s, size t len)

----- Set the SDES note item of the local participant to len and value to value.

[To be continued !]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.