James Kuszmaul | 4a42b18 | 2021-01-17 11:32:46 -0800 | [diff] [blame^] | 1 | #include "description.h" |
| 2 | #include <rawrtc/peer_connection_description.h> |
| 3 | #include <rawrtcc/code.h> |
| 4 | #include <rawrtcc/utils.h> |
| 5 | #include <re.h> |
| 6 | |
| 7 | /* |
| 8 | * Get the SDP type of the description. |
| 9 | */ |
| 10 | enum rawrtc_code rawrtc_peer_connection_description_get_sdp_type( |
| 11 | enum rawrtc_sdp_type* const typep, // de-referenced |
| 12 | struct rawrtc_peer_connection_description* const description) { |
| 13 | // Check arguments |
| 14 | if (!typep || !description) { |
| 15 | return RAWRTC_CODE_INVALID_ARGUMENT; |
| 16 | } |
| 17 | |
| 18 | // Set SDP type |
| 19 | *typep = description->type; |
| 20 | |
| 21 | // Done |
| 22 | return RAWRTC_CODE_SUCCESS; |
| 23 | } |
| 24 | |
| 25 | /* |
| 26 | * Get the SDP of the description. |
| 27 | * `*sdpp` will be set to a copy of the SDP that must be unreferenced. |
| 28 | */ |
| 29 | enum rawrtc_code rawrtc_peer_connection_description_get_sdp( |
| 30 | char** const sdpp, // de-referenced |
| 31 | struct rawrtc_peer_connection_description* const description) { |
| 32 | // Check arguments |
| 33 | if (!sdpp || !description) { |
| 34 | return RAWRTC_CODE_INVALID_ARGUMENT; |
| 35 | } |
| 36 | |
| 37 | // Copy SDP |
| 38 | return rawrtc_sdprintf(sdpp, "%b", description->sdp->buf, description->sdp->end); |
| 39 | } |