OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 } | 306 } |
307 | 307 |
308 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { | 308 size_t RepairedRtpStreamId::ValueSize(const std::string& rsid) { |
309 return RtpStreamId::ValueSize(rsid); | 309 return RtpStreamId::ValueSize(rsid); |
310 } | 310 } |
311 | 311 |
312 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { | 312 bool RepairedRtpStreamId::Write(uint8_t* data, const std::string& rsid) { |
313 return RtpStreamId::Write(data, rsid); | 313 return RtpStreamId::Write(data, rsid); |
314 } | 314 } |
315 | 315 |
316 // For Frame Marking RTP Header Extension: | |
317 // | |
318 // https://tools.ietf.org/html/draft-ietf-avtext-framemarking-04#page-4 | |
319 // This extensions provides meta-information about the RTP streams outside the | |
320 // encrypted media payload, an RTP switch can do codec-agnostic | |
321 // selective forwarding without decrypting the payload. | |
322 // | |
323 // for Non-Scalable Streams: | |
324 // | |
325 // 0 1 | |
326 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | |
327 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
328 // | ID=? | L=0 |S|E|I|D|0 0 0 0| | |
329 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
330 // | |
331 // for Scalable Streams: | |
332 // | |
333 // 0 1 2 3 | |
334 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
335 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
336 // | ID=? | L=2 |S|E|I|D|B| TID | LID | TL0PICIDX | | |
337 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
338 // | |
339 constexpr RTPExtensionType FrameMarking::kId; | |
340 constexpr const char* FrameMarking::kUri; | |
341 | |
342 bool FrameMarking::Parse(rtc::ArrayView<const uint8_t> data, | |
343 FrameMarks* frame_marks) { | |
344 RTC_DCHECK(frame_marks); | |
345 | |
346 if (data.empty()) | |
347 return false; | |
348 | |
349 // Set frame marking data | |
350 frame_marks->start_of_frame = (data[0] & 0x80) != 0; | |
351 frame_marks->end_of_frame = (data[0] & 0x40) != 0; | |
352 frame_marks->independent = (data[0] & 0x20) != 0; | |
353 frame_marks->discardable = (data[0] & 0x10) != 0; | |
354 | |
355 // Check variable length. | |
356 if (data.size() == 1) { | |
357 // We are non-scalable. | |
358 frame_marks->base_layer_sync = 0; | |
danilchap
2017/06/29 13:47:26
may be = false
sergio.garcia.murillo
2017/06/30 10:09:23
Done.
| |
359 frame_marks->temporal_layer_id = 0; | |
360 frame_marks->spatial_layer_id = 0; | |
361 frame_marks->tl0_pic_idx = 0; | |
362 } else if (data.size() == 3) { | |
363 // Set scalable parts | |
364 frame_marks->base_layer_sync = (data[0] & 0x08) != 0; | |
365 frame_marks->temporal_layer_id = (data[0] & 0x07) != 0; | |
366 frame_marks->spatial_layer_id = data[1]; | |
367 frame_marks->tl0_pic_idx = data[2]; | |
368 } else { | |
369 // Incorrect length. | |
370 return false; | |
371 } | |
372 return true; | |
373 } | |
374 | |
375 size_t FrameMarking::ValueSize(const FrameMarks& frame_marks) { | |
376 // Check if it is scalable. | |
377 if (frame_marks.base_layer_sync || | |
378 (frame_marks.temporal_layer_id && | |
379 frame_marks.temporal_layer_id != kNoTemporalIdx) || | |
380 (frame_marks.spatial_layer_id && | |
381 frame_marks.spatial_layer_id != kNoSpatialIdx) || | |
382 (frame_marks.tl0_pic_idx && | |
383 frame_marks.tl0_pic_idx != (uint8_t)kNoTl0PicIdx)) | |
384 return 3; | |
385 else | |
386 return 1; | |
387 } | |
388 | |
389 bool FrameMarking::Write(uint8_t* data, const FrameMarks& frame_marks) { | |
390 data[0] = frame_marks.start_of_frame ? 0x80 : 0x00; | |
391 data[0] |= frame_marks.end_of_frame ? 0x40 : 0x00; | |
392 data[0] |= frame_marks.independent ? 0x20 : 0x00; | |
393 data[0] |= frame_marks.discardable ? 0x10 : 0x00; | |
394 | |
395 // Check if it is scalable. | |
396 if (frame_marks.base_layer_sync || | |
397 (frame_marks.temporal_layer_id && | |
398 frame_marks.temporal_layer_id != kNoTemporalIdx) || | |
399 (frame_marks.spatial_layer_id && | |
400 frame_marks.spatial_layer_id != kNoSpatialIdx) || | |
401 (frame_marks.tl0_pic_idx && | |
402 frame_marks.tl0_pic_idx != static_cast<uint8_t>(kNoTl0PicIdx))) { | |
403 data[0] |= frame_marks.base_layer_sync ? 0x08 : 0x00; | |
404 data[0] |= (frame_marks.temporal_layer_id & 0x07); | |
405 data[1] = frame_marks.spatial_layer_id; | |
406 data[2] = frame_marks.tl0_pic_idx; | |
407 } | |
408 return true; | |
409 } | |
410 | |
316 } // namespace webrtc | 411 } // namespace webrtc |
OLD | NEW |