Skip to content

Commit

Permalink
Replace rtc::Optional with absl::optional
Browse files Browse the repository at this point in the history
This is a no-op change because rtc::Optional is an alias to absl::optional

This CL generated by running script passing top level directories except rtc_base and api

find $@ -type f \( -name \*.h -o -name \*.cc -o -name \*.mm \) \
-exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \
-exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \
-exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+

find $@ -type f -name BUILD.gn \
-exec sed -r -i 's|"[\./api]*:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+;

git cl format

Bug: webrtc:9078
Change-Id: I9465c172e65ba6e6ed4e4fdc35b0b265038d6f71
Reviewed-on: https://webrtc-review.googlesource.com/84584
Reviewed-by: Karl Wiberg <[email protected]>
Commit-Queue: Danil Chapovalov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#23697}
  • Loading branch information
DanilChapovalov authored and Commit Bot committed Jun 21, 2018
1 parent ae810c1 commit 196100e
Show file tree
Hide file tree
Showing 71 changed files with 189 additions and 188 deletions.
2 changes: 1 addition & 1 deletion common_audio/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ rtc_static_library("common_audio") {
":sinc_resampler",
"..:webrtc_common",
"../:typedefs",
"../api:optional",
"../rtc_base:checks",
"../rtc_base:gtest_prod",
"../rtc_base:rtc_base_approved",
"../rtc_base/memory:aligned_array",
"../rtc_base/memory:aligned_malloc",
"../system_wrappers",
"../system_wrappers:cpu_features_api",
"//third_party/abseil-cpp/absl/types:optional",
]

defines = []
Expand Down
2 changes: 1 addition & 1 deletion common_audio/mocks/mock_smoothing_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace webrtc {
class MockSmoothingFilter : public SmoothingFilter {
public:
MOCK_METHOD1(AddSample, void(float));
MOCK_METHOD0(GetAverage, rtc::Optional<float>());
MOCK_METHOD0(GetAverage, absl::optional<float>());
MOCK_METHOD1(SetTimeConstantMs, bool(int));
};

Expand Down
4 changes: 2 additions & 2 deletions common_audio/smoothing_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ void SmoothingFilterImpl::AddSample(float sample) {
last_sample_ = sample;
}

rtc::Optional<float> SmoothingFilterImpl::GetAverage() {
absl::optional<float> SmoothingFilterImpl::GetAverage() {
if (!init_end_time_ms_) {
// |init_end_time_ms_| undefined since we have not received any sample.
return rtc::nullopt;
return absl::nullopt;
}
ExtrapolateLastSample(rtc::TimeMillis());
return state_;
Expand Down
8 changes: 4 additions & 4 deletions common_audio/smoothing_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef COMMON_AUDIO_SMOOTHING_FILTER_H_
#define COMMON_AUDIO_SMOOTHING_FILTER_H_

#include "api/optional.h"
#include "absl/types/optional.h"
#include "rtc_base/constructormagic.h"
#include "system_wrappers/include/clock.h"

Expand All @@ -21,7 +21,7 @@ class SmoothingFilter {
public:
virtual ~SmoothingFilter() = default;
virtual void AddSample(float sample) = 0;
virtual rtc::Optional<float> GetAverage() = 0;
virtual absl::optional<float> GetAverage() = 0;
virtual bool SetTimeConstantMs(int time_constant_ms) = 0;
};

Expand All @@ -44,7 +44,7 @@ class SmoothingFilterImpl final : public SmoothingFilter {
~SmoothingFilterImpl() override;

void AddSample(float sample) override;
rtc::Optional<float> GetAverage() override;
absl::optional<float> GetAverage() override;
bool SetTimeConstantMs(int time_constant_ms) override;

// Methods used for unittests.
Expand All @@ -58,7 +58,7 @@ class SmoothingFilterImpl final : public SmoothingFilter {
const float init_factor_;
const float init_const_;

rtc::Optional<int64_t> init_end_time_ms_;
absl::optional<int64_t> init_end_time_ms_;
float last_sample_;
float alpha_;
float state_;
Expand Down
2 changes: 1 addition & 1 deletion common_video/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ rtc_static_library("common_video") {
deps = [
"..:webrtc_common",
"../:typedefs",
"../api:optional",
"../api/video:video_bitrate_allocation",
"../api/video:video_frame",
"../api/video:video_frame_i420",
Expand All @@ -67,6 +66,7 @@ rtc_static_library("common_video") {
"../rtc_base:rtc_base",
"../rtc_base:rtc_task_queue",
"../rtc_base:safe_minmax",
"//third_party/abseil-cpp/absl/types:optional",
"//third_party/libyuv",
]
}
Expand Down
2 changes: 1 addition & 1 deletion common_video/bitrate_adjuster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ uint32_t BitrateAdjuster::GetAdjustedBitrateBps() const {
return adjusted_bitrate_bps_;
}

rtc::Optional<uint32_t> BitrateAdjuster::GetEstimatedBitrateBps() {
absl::optional<uint32_t> BitrateAdjuster::GetEstimatedBitrateBps() {
rtc::CritScope cs(&crit_);
return bitrate_tracker_.Rate(rtc::TimeMillis());
}
Expand Down
2 changes: 1 addition & 1 deletion common_video/h264/h264_bitstream_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ H264BitstreamParser::Result H264BitstreamParser::ParseNonParameterSetNalu(
if (!sps_ || !pps_)
return kInvalidStream;

last_slice_qp_delta_ = rtc::nullopt;
last_slice_qp_delta_ = absl::nullopt;
const std::vector<uint8_t> slice_rbsp =
H264::ParseRbsp(source, source_length);
if (slice_rbsp.size() < H264::kNaluTypeSize)
Expand Down
8 changes: 4 additions & 4 deletions common_video/h264/h264_bitstream_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <stddef.h>
#include <stdint.h>

#include "api/optional.h"
#include "absl/types/optional.h"
#include "common_video/h264/pps_parser.h"
#include "common_video/h264/sps_parser.h"

Expand Down Expand Up @@ -53,11 +53,11 @@ class H264BitstreamParser {
uint8_t nalu_type);

// SPS/PPS state, updated when parsing new SPS/PPS, used to parse slices.
rtc::Optional<SpsParser::SpsState> sps_;
rtc::Optional<PpsParser::PpsState> pps_;
absl::optional<SpsParser::SpsState> sps_;
absl::optional<PpsParser::PpsState> pps_;

// Last parsed slice QP.
rtc::Optional<int32_t> last_slice_qp_delta_;
absl::optional<int32_t> last_slice_qp_delta_;
};

} // namespace webrtc
Expand Down
18 changes: 9 additions & 9 deletions common_video/h264/pps_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#define RETURN_EMPTY_ON_FAIL(x) \
if (!(x)) { \
return rtc::nullopt; \
return absl::nullopt; \
}

namespace {
Expand All @@ -33,8 +33,8 @@ namespace webrtc {
// You can find it on this page:
// http://www.itu.int/rec/T-REC-H.264

rtc::Optional<PpsParser::PpsState> PpsParser::ParsePps(const uint8_t* data,
size_t length) {
absl::optional<PpsParser::PpsState> PpsParser::ParsePps(const uint8_t* data,
size_t length) {
// First, parse out rbsp, which is basically the source buffer minus emulation
// bytes (the last byte of a 0x00 0x00 0x03 sequence). RBSP is defined in
// section 7.3.1 of the H.264 standard.
Expand All @@ -57,26 +57,26 @@ bool PpsParser::ParsePpsIds(const uint8_t* data,
return ParsePpsIdsInternal(&bit_buffer, pps_id, sps_id);
}

rtc::Optional<uint32_t> PpsParser::ParsePpsIdFromSlice(const uint8_t* data,
size_t length) {
absl::optional<uint32_t> PpsParser::ParsePpsIdFromSlice(const uint8_t* data,
size_t length) {
std::vector<uint8_t> unpacked_buffer = H264::ParseRbsp(data, length);
rtc::BitBuffer slice_reader(unpacked_buffer.data(), unpacked_buffer.size());

uint32_t golomb_tmp;
// first_mb_in_slice: ue(v)
if (!slice_reader.ReadExponentialGolomb(&golomb_tmp))
return rtc::nullopt;
return absl::nullopt;
// slice_type: ue(v)
if (!slice_reader.ReadExponentialGolomb(&golomb_tmp))
return rtc::nullopt;
return absl::nullopt;
// pic_parameter_set_id: ue(v)
uint32_t slice_pps_id;
if (!slice_reader.ReadExponentialGolomb(&slice_pps_id))
return rtc::nullopt;
return absl::nullopt;
return slice_pps_id;
}

rtc::Optional<PpsParser::PpsState> PpsParser::ParseInternal(
absl::optional<PpsParser::PpsState> PpsParser::ParseInternal(
rtc::BitBuffer* bit_buffer) {
PpsState pps;

Expand Down
10 changes: 5 additions & 5 deletions common_video/h264/pps_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef COMMON_VIDEO_H264_PPS_PARSER_H_
#define COMMON_VIDEO_H264_PPS_PARSER_H_

#include "api/optional.h"
#include "absl/types/optional.h"

namespace rtc {
class BitBuffer;
Expand All @@ -38,20 +38,20 @@ class PpsParser {
};

// Unpack RBSP and parse PPS state from the supplied buffer.
static rtc::Optional<PpsState> ParsePps(const uint8_t* data, size_t length);
static absl::optional<PpsState> ParsePps(const uint8_t* data, size_t length);

static bool ParsePpsIds(const uint8_t* data,
size_t length,
uint32_t* pps_id,
uint32_t* sps_id);

static rtc::Optional<uint32_t> ParsePpsIdFromSlice(const uint8_t* data,
size_t length);
static absl::optional<uint32_t> ParsePpsIdFromSlice(const uint8_t* data,
size_t length);

protected:
// Parse the PPS state, for a bit buffer where RBSP decoding has already been
// performed.
static rtc::Optional<PpsState> ParseInternal(rtc::BitBuffer* bit_buffer);
static absl::optional<PpsState> ParseInternal(rtc::BitBuffer* bit_buffer);
static bool ParsePpsIdsInternal(rtc::BitBuffer* bit_buffer,
uint32_t* pps_id,
uint32_t* sps_id);
Expand Down
4 changes: 2 additions & 2 deletions common_video/h264/pps_parser_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class PpsParserTest : public ::testing::Test {

PpsParser::PpsState generated_pps_;
rtc::Buffer buffer_;
rtc::Optional<PpsParser::PpsState> parsed_pps_;
absl::optional<PpsParser::PpsState> parsed_pps_;
};

TEST_F(PpsParserTest, ZeroPps) {
Expand All @@ -215,7 +215,7 @@ TEST_F(PpsParserTest, MaxPps) {
}

TEST_F(PpsParserTest, PpsIdFromSlice) {
rtc::Optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice(
absl::optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice(
kH264BitstreamChunk, sizeof(kH264BitstreamChunk));
ASSERT_TRUE(pps_id);
EXPECT_EQ(2u, *pps_id);
Expand Down
4 changes: 2 additions & 2 deletions common_video/h264/profile_level_id_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ TEST(H264ProfileLevelId, TestToStringInvalid) {
}

TEST(H264ProfileLevelId, TestParseSdpProfileLevelIdEmpty) {
const rtc::Optional<ProfileLevelId> profile_level_id =
const absl::optional<ProfileLevelId> profile_level_id =
ParseSdpProfileLevelId(CodecParameterMap());
EXPECT_TRUE(profile_level_id);
EXPECT_EQ(kProfileConstrainedBaseline, profile_level_id->profile);
Expand All @@ -135,7 +135,7 @@ TEST(H264ProfileLevelId, TestParseSdpProfileLevelIdEmpty) {
TEST(H264ProfileLevelId, TestParseSdpProfileLevelIdConstrainedHigh) {
CodecParameterMap params;
params["profile-level-id"] = "640c2a";
const rtc::Optional<ProfileLevelId> profile_level_id =
const absl::optional<ProfileLevelId> profile_level_id =
ParseSdpProfileLevelId(params);
EXPECT_TRUE(profile_level_id);
EXPECT_EQ(kProfileConstrainedHigh, profile_level_id->profile);
Expand Down
8 changes: 4 additions & 4 deletions common_video/h264/sps_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "rtc_base/logging.h"

namespace {
typedef rtc::Optional<webrtc::SpsParser::SpsState> OptionalSps;
typedef absl::optional<webrtc::SpsParser::SpsState> OptionalSps;

#define RETURN_EMPTY_ON_FAIL(x) \
if (!(x)) { \
Expand All @@ -38,14 +38,14 @@ SpsParser::SpsState::SpsState() = default;
// http://www.itu.int/rec/T-REC-H.264

// Unpack RBSP and parse SPS state from the supplied buffer.
rtc::Optional<SpsParser::SpsState> SpsParser::ParseSps(const uint8_t* data,
size_t length) {
absl::optional<SpsParser::SpsState> SpsParser::ParseSps(const uint8_t* data,
size_t length) {
std::vector<uint8_t> unpacked_buffer = H264::ParseRbsp(data, length);
rtc::BitBuffer bit_buffer(unpacked_buffer.data(), unpacked_buffer.size());
return ParseSpsUpToVui(&bit_buffer);
}

rtc::Optional<SpsParser::SpsState> SpsParser::ParseSpsUpToVui(
absl::optional<SpsParser::SpsState> SpsParser::ParseSpsUpToVui(
rtc::BitBuffer* buffer) {
// Now, we need to use a bit buffer to parse through the actual AVC SPS
// format. See Section 7.3.2.1.1 ("Sequence parameter set data syntax") of the
Expand Down
6 changes: 3 additions & 3 deletions common_video/h264/sps_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef COMMON_VIDEO_H264_SPS_PARSER_H_
#define COMMON_VIDEO_H264_SPS_PARSER_H_

#include "api/optional.h"
#include "absl/types/optional.h"

namespace rtc {
class BitBuffer;
Expand Down Expand Up @@ -41,12 +41,12 @@ class SpsParser {
};

// Unpack RBSP and parse SPS state from the supplied buffer.
static rtc::Optional<SpsState> ParseSps(const uint8_t* data, size_t length);
static absl::optional<SpsState> ParseSps(const uint8_t* data, size_t length);

protected:
// Parse the SPS state, up till the VUI part, for a bit buffer where RBSP
// decoding has already been performed.
static rtc::Optional<SpsState> ParseSpsUpToVui(rtc::BitBuffer* buffer);
static absl::optional<SpsState> ParseSpsUpToVui(rtc::BitBuffer* buffer);
};

} // namespace webrtc
Expand Down
2 changes: 1 addition & 1 deletion common_video/h264/sps_parser_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class H264SpsParserTest : public ::testing::Test {
H264SpsParserTest() {}
virtual ~H264SpsParserTest() {}

rtc::Optional<SpsParser::SpsState> sps_;
absl::optional<SpsParser::SpsState> sps_;
};

TEST_F(H264SpsParserTest, TestSampleSPSHdLandscape) {
Expand Down
4 changes: 2 additions & 2 deletions common_video/h264/sps_vui_rewriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ bool CopyRemainingBits(rtc::BitBuffer* source,
SpsVuiRewriter::ParseResult SpsVuiRewriter::ParseAndRewriteSps(
const uint8_t* buffer,
size_t length,
rtc::Optional<SpsParser::SpsState>* sps,
absl::optional<SpsParser::SpsState>* sps,
rtc::Buffer* destination) {
// Create temporary RBSP decoded buffer of the payload (exlcuding the
// leading nalu type header byte (the SpsParser uses only the payload).
std::vector<uint8_t> rbsp_buffer = H264::ParseRbsp(buffer, length);
rtc::BitBuffer source_buffer(rbsp_buffer.data(), rbsp_buffer.size());
rtc::Optional<SpsParser::SpsState> sps_state =
absl::optional<SpsParser::SpsState> sps_state =
SpsParser::ParseSpsUpToVui(&source_buffer);
if (!sps_state)
return ParseResult::kFailure;
Expand Down
11 changes: 6 additions & 5 deletions common_video/h264/sps_vui_rewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#ifndef COMMON_VIDEO_H264_SPS_VUI_REWRITER_H_
#define COMMON_VIDEO_H264_SPS_VUI_REWRITER_H_

#include "api/optional.h"
#include "absl/types/optional.h"
#include "common_video/h264/sps_parser.h"
#include "rtc_base/buffer.h"

Expand Down Expand Up @@ -43,10 +43,11 @@ class SpsVuiRewriter : private SpsParser {
// SPS state. This function assumes that any previous headers
// (NALU start, type, Stap-A, etc) have already been parsed and that RBSP
// decoding has been performed.
static ParseResult ParseAndRewriteSps(const uint8_t* buffer,
size_t length,
rtc::Optional<SpsParser::SpsState>* sps,
rtc::Buffer* destination);
static ParseResult ParseAndRewriteSps(
const uint8_t* buffer,
size_t length,
absl::optional<SpsParser::SpsState>* sps,
rtc::Buffer* destination);
};

} // namespace webrtc
Expand Down
2 changes: 1 addition & 1 deletion common_video/h264/sps_vui_rewriter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void TestSps(SpsMode mode, SpsVuiRewriter::ParseResult expected_parse_result) {
index.payload_start_offset += H264::kNaluTypeSize;
index.payload_size -= H264::kNaluTypeSize;

rtc::Optional<SpsParser::SpsState> sps;
absl::optional<SpsParser::SpsState> sps;
rtc::Buffer out_buffer;
SpsVuiRewriter::ParseResult result =
SpsVuiRewriter::ParseAndRewriteSps(&buffer[index.payload_start_offset],
Expand Down
2 changes: 1 addition & 1 deletion common_video/include/bitrate_adjuster.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BitrateAdjuster {
uint32_t GetAdjustedBitrateBps() const;

// Returns what we think the current bitrate is.
rtc::Optional<uint32_t> GetEstimatedBitrateBps();
absl::optional<uint32_t> GetEstimatedBitrateBps();

// This should be called after each frame is encoded. The timestamp at which
// it is called is used to estimate the output bitrate of the encoder.
Expand Down
2 changes: 1 addition & 1 deletion common_video/incoming_video_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void IncomingVideoStream::OnFrame(const VideoFrame& video_frame) {
void IncomingVideoStream::Dequeue() {
TRACE_EVENT0("webrtc", "IncomingVideoStream::Dequeue");
RTC_DCHECK(incoming_render_queue_.IsCurrent());
rtc::Optional<VideoFrame> frame_to_render = render_buffers_.FrameToRender();
absl::optional<VideoFrame> frame_to_render = render_buffers_.FrameToRender();
if (frame_to_render)
callback_->OnFrame(*frame_to_render);

Expand Down
4 changes: 2 additions & 2 deletions common_video/video_render_frames.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ int32_t VideoRenderFrames::AddFrame(VideoFrame&& new_frame) {
return static_cast<int32_t>(incoming_frames_.size());
}

rtc::Optional<VideoFrame> VideoRenderFrames::FrameToRender() {
rtc::Optional<VideoFrame> render_frame;
absl::optional<VideoFrame> VideoRenderFrames::FrameToRender() {
absl::optional<VideoFrame> render_frame;
// Get the newest frame that can be released for rendering.
while (!incoming_frames_.empty() && TimeToNextFrameRelease() <= 0) {
render_frame = std::move(incoming_frames_.front());
Expand Down
Loading

0 comments on commit 196100e

Please sign in to comment.