Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: webrtc/common_types.h

Issue 2434073003: Extract bitrate allocation of spatial/temporal layers out of codec impl. (Closed)
Patch Set: Fixed test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #ifndef WEBRTC_COMMON_TYPES_H_ 11 #ifndef WEBRTC_COMMON_TYPES_H_
12 #define WEBRTC_COMMON_TYPES_H_ 12 #define WEBRTC_COMMON_TYPES_H_
13 13
14 #include <assert.h> 14 #include <assert.h>
15 #include <stddef.h> 15 #include <stddef.h>
16 #include <string.h> 16 #include <string.h>
17 17
18 #include <string> 18 #include <string>
19 #include <vector> 19 #include <vector>
20 20
21 #include "webrtc/base/optional.h"
21 #include "webrtc/common_video/rotation.h" 22 #include "webrtc/common_video/rotation.h"
22 #include "webrtc/typedefs.h" 23 #include "webrtc/typedefs.h"
23 24
24 #if defined(_MSC_VER) 25 #if defined(_MSC_VER)
25 // Disable "new behavior: elements of array will be default initialized" 26 // Disable "new behavior: elements of array will be default initialized"
26 // warning. Affects OverUseDetectorOptions. 27 // warning. Affects OverUseDetectorOptions.
27 #pragma warning(disable : 4351) 28 #pragma warning(disable : 4351)
28 #endif 29 #endif
29 30
30 #if defined(WEBRTC_EXPORT) 31 #if defined(WEBRTC_EXPORT)
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 bool pictureLossIndicationOn; 516 bool pictureLossIndicationOn;
516 bool feedbackModeOn; 517 bool feedbackModeOn;
517 VideoCodecComplexity complexity; 518 VideoCodecComplexity complexity;
518 VP8ResilienceMode resilience; 519 VP8ResilienceMode resilience;
519 unsigned char numberOfTemporalLayers; 520 unsigned char numberOfTemporalLayers;
520 bool denoisingOn; 521 bool denoisingOn;
521 bool errorConcealmentOn; 522 bool errorConcealmentOn;
522 bool automaticResizeOn; 523 bool automaticResizeOn;
523 bool frameDroppingOn; 524 bool frameDroppingOn;
524 int keyFrameInterval; 525 int keyFrameInterval;
525 const TemporalLayersFactory* tl_factory; 526 TemporalLayersFactory* tl_factory;
526 }; 527 };
527 528
528 // VP9 specific. 529 // VP9 specific.
529 struct VideoCodecVP9 { 530 struct VideoCodecVP9 {
530 VideoCodecComplexity complexity; 531 VideoCodecComplexity complexity;
531 int resilience; 532 int resilience;
532 unsigned char numberOfTemporalLayers; 533 unsigned char numberOfTemporalLayers;
533 bool denoisingOn; 534 bool denoisingOn;
534 bool frameDroppingOn; 535 bool frameDroppingOn;
535 int keyFrameInterval; 536 int keyFrameInterval;
(...skipping 19 matching lines...) Expand all
555 kVideoCodecVP8, 556 kVideoCodecVP8,
556 kVideoCodecVP9, 557 kVideoCodecVP9,
557 kVideoCodecH264, 558 kVideoCodecH264,
558 kVideoCodecI420, 559 kVideoCodecI420,
559 kVideoCodecRED, 560 kVideoCodecRED,
560 kVideoCodecULPFEC, 561 kVideoCodecULPFEC,
561 kVideoCodecGeneric, 562 kVideoCodecGeneric,
562 kVideoCodecUnknown 563 kVideoCodecUnknown
563 }; 564 };
564 565
566 // Translates from name of codec to codec type and vice versa.
567 rtc::Optional<std::string> CodecTypeToPayloadName(VideoCodecType type);
568 rtc::Optional<VideoCodecType> PayloadNameToCodecType(const std::string& name);
569
565 union VideoCodecUnion { 570 union VideoCodecUnion {
566 VideoCodecVP8 VP8; 571 VideoCodecVP8 VP8;
567 VideoCodecVP9 VP9; 572 VideoCodecVP9 VP9;
568 VideoCodecH264 H264; 573 VideoCodecH264 H264;
569 }; 574 };
570 575
571 // Simulcast is when the same stream is encoded multiple times with different 576 // Simulcast is when the same stream is encoded multiple times with different
572 // settings such as resolution. 577 // settings such as resolution.
573 struct SimulcastStream { 578 struct SimulcastStream {
574 unsigned short width; 579 unsigned short width;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 VideoCodecH264* H264(); 636 VideoCodecH264* H264();
632 const VideoCodecH264& H264() const; 637 const VideoCodecH264& H264() const;
633 638
634 // This variable will be declared private and renamed to codec_specific_ 639 // This variable will be declared private and renamed to codec_specific_
635 // once Chromium is not accessing it. 640 // once Chromium is not accessing it.
636 // TODO(hta): Consider replacing the union with a pointer type. 641 // TODO(hta): Consider replacing the union with a pointer type.
637 // This will allow removing the VideoCodec* types from this file. 642 // This will allow removing the VideoCodec* types from this file.
638 VideoCodecUnion codecSpecific; 643 VideoCodecUnion codecSpecific;
639 }; 644 };
640 645
646 class BitrateAllocation {
647 public:
648 static const size_t kMaxBitrateBps;
649 BitrateAllocation();
650
651 bool SetBitrate(size_t spatial_index,
652 size_t temporal_index,
653 uint32_t bitrate_bps);
654
655 uint32_t GetBitrate(size_t spatial_index, size_t temporal_index) const;
656
657 // Get the sum of all the temporal layer for a specific spatial layer.
658 uint32_t GetSpatialLayerSum(size_t spatial_index) const;
659
660 uint32_t get_sum_bps() const { return sum_; } // Sum of all bitrates.
661 uint32_t get_sum_kbps() const { return (sum_ + 500) / 1000; }
662
663 inline bool operator==(const BitrateAllocation& other) const {
664 return memcmp(bitrates_, other.bitrates_, sizeof(bitrates_)) == 0;
665 }
666 inline bool operator!=(const BitrateAllocation& other) const {
667 return !(*this == other);
668 }
669
670 private:
671 uint32_t sum_;
672 uint32_t bitrates_[kMaxSpatialLayers][kMaxTemporalStreams];
673 };
674
641 // Bandwidth over-use detector options. These are used to drive 675 // Bandwidth over-use detector options. These are used to drive
642 // experimentation with bandwidth estimation parameters. 676 // experimentation with bandwidth estimation parameters.
643 // See modules/remote_bitrate_estimator/overuse_detector.h 677 // See modules/remote_bitrate_estimator/overuse_detector.h
644 struct OverUseDetectorOptions { 678 struct OverUseDetectorOptions {
645 OverUseDetectorOptions() 679 OverUseDetectorOptions()
646 : initial_slope(8.0 / 512.0), 680 : initial_slope(8.0 / 512.0),
647 initial_offset(0), 681 initial_offset(0),
648 initial_e(), 682 initial_e(),
649 initial_process_noise(), 683 initial_process_noise(),
650 initial_avg_noise(0.0), 684 initial_avg_noise(0.0),
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 enum class RtcpMode { kOff, kCompound, kReducedSize }; 871 enum class RtcpMode { kOff, kCompound, kReducedSize };
838 872
839 enum NetworkState { 873 enum NetworkState {
840 kNetworkUp, 874 kNetworkUp,
841 kNetworkDown, 875 kNetworkDown,
842 }; 876 };
843 877
844 } // namespace webrtc 878 } // namespace webrtc
845 879
846 #endif // WEBRTC_COMMON_TYPES_H_ 880 #endif // WEBRTC_COMMON_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698