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 | |
317 // For Frame Marking RTP Header Extension: | |
318 // | |
319 // https://tools.ietf.org/html/draft-ietf-avtext-framemarking-04#page-4 | |
320 // This extensions provides meta-information about the RTP streams outside the | |
321 // encrypted media payload, an RTP switch can do codec-agnostic | |
322 // selective forwarding without decrypting the payload | |
323 // | |
324 // for Non-Scalable Streams | |
325 // | |
326 // 0 1 | |
327 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | |
328 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
329 // | ID=? | L=0 |S|E|I|D|0 0 0 0| | |
330 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
331 // | |
332 // for Scalable Streams | |
333 // | |
334 // 0 1 2 3 | |
335 // 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 | |
336 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
337 // | ID=? | L=2 |S|E|I|D|B| TID | LID | TL0PICIDX | | |
338 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
339 // | |
340 constexpr RTPExtensionType FrameMarking::kId; | |
341 constexpr const char* FrameMarking::kUri; | |
342 | |
343 bool FrameMarking::Parse(const uint8_t* data, | |
344 uint8_t length, | |
345 FrameMarks* frame_marks) { | |
346 RTC_DCHECK(frame_marks); | |
347 RTC_DCHECK(length); | |
348 // Set frame marking data | |
349 frame_marks->startOfFrame = (data[0] & 0x80) != 0; | |
350 frame_marks->endOfFrame = (data[0] & 0x40) != 0; | |
351 frame_marks->independent = (data[0] & 0x20) != 0; | |
352 frame_marks->discardable = (data[0] & 0x10) != 0; | |
353 | |
354 // Check variable length | |
355 if (length==1) { | |
danilchap
2017/06/28 16:07:06
please use git cl format (to add spaces around '==
sergio.garcia.murillo
2017/06/29 12:58:58
Done.
| |
356 // We are non-scalable | |
357 frame_marks->baseLayerSync = 0; | |
358 frame_marks->temporalLayerId = 0; | |
359 frame_marks->spatialLayerId = 0; | |
360 frame_marks->tl0PicIdx = 0; | |
361 } else if (length==3) { | |
362 // Set scalable parts | |
363 frame_marks->baseLayerSync = (data[0] & 0x08) != 0; | |
364 frame_marks->temporalLayerId = (data[0] & 0x07) != 0; | |
danilchap
2017/06/28 16:07:06
remove "!= 0"
sergio.garcia.murillo
2017/06/29 12:58:57
msvc gives C4800 warning: forcing value to bool 't
danilchap
2017/06/29 13:47:26
is temporal_layer_id a boolean field?
sergio.garcia.murillo
2017/06/30 10:09:23
uuuupsss!
| |
365 frame_marks->spatialLayerId = data[1]; | |
366 frame_marks->tl0PicIdx = data[2]; | |
367 } else { | |
368 // Incorrect length | |
369 return false; | |
370 } | |
371 return true; | |
372 } | |
373 | |
374 size_t FrameMarking::ValueSize(const FrameMarks& frame_marks) { | |
375 // Check if it is scalable | |
376 if (frame_marks.baseLayerSync | |
377 || (frame_marks.temporalLayerId | |
378 && frame_marks.temporalLayerId != kNoTemporalIdx) | |
379 || (frame_marks.spatialLayerId | |
380 && frame_marks.spatialLayerId != kNoSpatialIdx) | |
381 || (frame_marks.tl0PicIdx | |
382 && frame_marks.tl0PicIdx != (uint8_t)kNoTl0PicIdx) | |
danilchap
2017/06/28 16:07:06
use static_cast instead of c-cast,
sergio.garcia.murillo
2017/06/29 12:58:58
Done.
danilchap
2017/06/29 13:47:26
still c-cast in this line
sergio.garcia.murillo
2017/06/30 10:09:23
Done. This time for sure.
| |
383 ) | |
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.startOfFrame ? 0x80 : 0x00; | |
391 data[0] |= frame_marks.endOfFrame ? 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.baseLayerSync | |
397 || (frame_marks.temporalLayerId | |
danilchap
2017/06/28 16:07:06
is temporal_layer_id == 0 a value that shouldn't b
sergio.garcia.murillo
2017/06/29 12:58:57
No, but if temporal and spatial layer are 0 and tl
| |
398 && frame_marks.temporalLayerId != kNoTemporalIdx) | |
399 || (frame_marks.spatialLayerId | |
400 && frame_marks.spatialLayerId != kNoSpatialIdx) | |
401 || (frame_marks.tl0PicIdx | |
402 && frame_marks.tl0PicIdx != (uint8_t)kNoTl0PicIdx) | |
403 ) { | |
404 data[0] |= frame_marks.baseLayerSync ? 0x08 : 0x00; | |
405 data[0] |= (frame_marks.temporalLayerId & 0x07); | |
406 data[1] = frame_marks.spatialLayerId; | |
407 data[2] = frame_marks.tl0PicIdx; | |
408 } | |
409 return true; | |
410 } | |
411 | |
316 } // namespace webrtc | 412 } // namespace webrtc |
OLD | NEW |