kjellander a96e2d77cb Move talk/media to webrtc/media
I removed the 'libjingle' target in talk/libjingle.gyp and replaced
all users of it with base/base.gyp:rtc_base. It seems the jsoncpp
and expat dependencies were not used by it's previous references.

The files in talk/media/testdata were uploaded to Google Storage and
added .sha1 files in resources/media instead of simply moving them.

The previously disabled warnings that were inherited from
talk/build/common.gypi are now replaced by target-specific disabling
of only the failing warnings. Additional disabling was needed since the stricter
compilation warnings that applies to code in webrtc/.

License headers will be updated in a follow-up CL in order to not
break Git history.

Other modifications:
* Updated the header guards.
* Sorted the includes using chromium/src/tools/sort-headers.py
  except for these files:
  talk/app/webrtc/peerconnectionendtoend_unittest.cc
  talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
  talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
  webrtc/media/devices/win32devicemanager.cc.
* Unused GYP reference to libjingle_tests_additional_deps was removed.
* Removed duplicated GYP entries of
  webrtc/base/testutils.cc
  webrtc/base/testutils.h

The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media,
so they were moved to the media.gyp.

I also checked that none of
EXPAT_RELATIVE_PATH,
FEATURE_ENABLE_VOICEMAIL,
GTEST_RELATIVE_PATH,
JSONCPP_RELATIVE_PATH,
LOGGING=1,
SRTP_RELATIVE_PATH,
FEATURE_ENABLE_SSL,
FEATURE_ENABLE_VOICEMAIL,
FEATURE_ENABLE_PSTN,
HAVE_SCTP,
HAVE_SRTP,
are used by the talk/media code.

For Chromium, the following changes will need to be applied to the roll CL that updates the
DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/

BUG=webrtc:5420
NOPRESUBMIT=True
TBR=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1587193006

Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-05 07:52:35 +00:00

245 lines
7.0 KiB
C++

/*
* libjingle
* Copyright 2004 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WEBRTC_MEDIA_BASE_CODEC_H_
#define WEBRTC_MEDIA_BASE_CODEC_H_
#include <map>
#include <set>
#include <string>
#include <vector>
#include "webrtc/media/base/constants.h"
namespace cricket {
typedef std::map<std::string, std::string> CodecParameterMap;
extern const int kMaxPayloadId;
class FeedbackParam {
public:
FeedbackParam(const std::string& id, const std::string& param)
: id_(id),
param_(param) {
}
explicit FeedbackParam(const std::string& id)
: id_(id),
param_(kParamValueEmpty) {
}
bool operator==(const FeedbackParam& other) const;
const std::string& id() const { return id_; }
const std::string& param() const { return param_; }
private:
std::string id_; // e.g. "nack", "ccm"
std::string param_; // e.g. "", "rpsi", "fir"
};
class FeedbackParams {
public:
bool operator==(const FeedbackParams& other) const;
bool Has(const FeedbackParam& param) const;
void Add(const FeedbackParam& param);
void Intersect(const FeedbackParams& from);
const std::vector<FeedbackParam>& params() const { return params_; }
private:
bool HasDuplicateEntries() const;
std::vector<FeedbackParam> params_;
};
struct Codec {
int id;
std::string name;
int clockrate;
int preference;
CodecParameterMap params;
FeedbackParams feedback_params;
// Creates a codec with the given parameters.
Codec(int id, const std::string& name, int clockrate, int preference);
// Creates an empty codec.
Codec();
Codec(const Codec& c);
~Codec();
// Indicates if this codec is compatible with the specified codec.
bool Matches(const Codec& codec) const;
// Find the parameter for |name| and write the value to |out|.
bool GetParam(const std::string& name, std::string* out) const;
bool GetParam(const std::string& name, int* out) const;
void SetParam(const std::string& name, const std::string& value);
void SetParam(const std::string& name, int value);
// It is safe to input a non-existent parameter.
// Returns true if the parameter existed, false if it did not exist.
bool RemoveParam(const std::string& name);
bool HasFeedbackParam(const FeedbackParam& param) const;
void AddFeedbackParam(const FeedbackParam& param);
static bool Preferable(const Codec& first, const Codec& other) {
return first.preference > other.preference;
}
// Filter |this| feedbacks params such that only those shared by both |this|
// and |other| are kept.
void IntersectFeedbackParams(const Codec& other);
Codec& operator=(const Codec& c);
bool operator==(const Codec& c) const;
bool operator!=(const Codec& c) const {
return !(*this == c);
}
};
struct AudioCodec : public Codec {
int bitrate;
size_t channels;
// Creates a codec with the given parameters.
AudioCodec(int id,
const std::string& name,
int clockrate,
int bitrate,
size_t channels,
int preference);
// Creates an empty codec.
AudioCodec();
AudioCodec(const AudioCodec& c);
~AudioCodec() = default;
// Indicates if this codec is compatible with the specified codec.
bool Matches(const AudioCodec& codec) const;
static bool Preferable(const AudioCodec& first, const AudioCodec& other) {
return first.preference > other.preference;
}
std::string ToString() const;
AudioCodec& operator=(const AudioCodec& c);
bool operator==(const AudioCodec& c) const;
bool operator!=(const AudioCodec& c) const {
return !(*this == c);
}
};
struct VideoCodec : public Codec {
int width;
int height;
int framerate;
// Creates a codec with the given parameters.
VideoCodec(int id,
const std::string& name,
int width,
int height,
int framerate,
int preference);
VideoCodec(int id, const std::string& name);
// Creates an empty codec.
VideoCodec();
VideoCodec(const VideoCodec& c);
~VideoCodec() = default;
static bool Preferable(const VideoCodec& first, const VideoCodec& other) {
return first.preference > other.preference;
}
std::string ToString() const;
VideoCodec& operator=(const VideoCodec& c);
bool operator==(const VideoCodec& c) const;
bool operator!=(const VideoCodec& c) const {
return !(*this == c);
}
static VideoCodec CreateRtxCodec(int rtx_payload_type,
int associated_payload_type);
enum CodecType {
CODEC_VIDEO,
CODEC_RED,
CODEC_ULPFEC,
CODEC_RTX,
};
CodecType GetCodecType() const;
// Validates a VideoCodec's payload type, dimensions and bitrates etc. If they
// don't make sense (such as max < min bitrate), and error is logged and
// ValidateCodecFormat returns false.
bool ValidateCodecFormat() const;
};
struct DataCodec : public Codec {
DataCodec(int id, const std::string& name, int preference);
DataCodec();
DataCodec(const DataCodec& c);
DataCodec& operator=(const DataCodec& c);
std::string ToString() const;
};
// Get the codec setting associated with |payload_type|. If there
// is no codec associated with that payload type it returns false.
template <class Codec>
bool FindCodecById(const std::vector<Codec>& codecs,
int payload_type,
Codec* codec_out) {
for (const auto& codec : codecs) {
if (codec.id == payload_type) {
*codec_out = codec;
return true;
}
}
return false;
}
bool CodecNamesEq(const std::string& name1, const std::string& name2);
bool HasNack(const Codec& codec);
bool HasRemb(const Codec& codec);
bool HasTransportCc(const Codec& codec);
} // namespace cricket
#endif // WEBRTC_MEDIA_BASE_CODEC_H_