128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org/*
228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * libjingle
35f93d0a140515e3b8cdd1b9a4c6f5871144e5deejlmiller@webrtc.org * Copyright 2013 Google Inc.
428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without
628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * modification, are permitted provided that the following conditions are met:
728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  1. Redistributions of source code must retain the above copyright notice,
928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     this list of conditions and the following disclaimer.
1028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  2. Redistributions in binary form must reproduce the above copyright notice,
1128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     this list of conditions and the following disclaimer in the documentation
1228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     and/or other materials provided with the distribution.
1328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  3. The name of the author may not be used to endorse or promote products
1428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     derived from this software without specific prior written permission.
1528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
1628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
1728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
1928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org */
2728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
2828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#ifndef TALK_MEDIA_WEBRTC_WEBRTCVIDEOENCODERFACTORY_H_
2928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#define TALK_MEDIA_WEBRTC_WEBRTCVIDEOENCODERFACTORY_H_
3028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/media/base/codec.h"
32a09a99950ec40aef6421e4ba35eee7196b7a6e68buildbot@webrtc.org#include "webrtc/base/refcount.h"
3328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "webrtc/common_types.h"
3428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgnamespace webrtc {
3628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgclass VideoEncoder;
3728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}
3828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgnamespace cricket {
4028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
4128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgclass WebRtcVideoEncoderFactory {
4228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org public:
4328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  struct VideoCodec {
4428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    webrtc::VideoCodecType type;
4528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::string name;
4628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int max_width;
4728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int max_height;
4828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int max_fps;
4928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
5028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    VideoCodec(webrtc::VideoCodecType t, const std::string& nm, int w, int h,
5128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org               int fr)
5228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        : type(t), name(nm), max_width(w), max_height(h), max_fps(fr) {
5328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
5428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
5528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
563c16d8bd1c0a3eea94a6678497eae0cf8e7f0187buildbot@webrtc.org  virtual ~WebRtcVideoEncoderFactory() {}
5728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
5828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // Caller takes the ownership of the returned object and it should be released
5928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // by calling DestroyVideoEncoder().
6028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual webrtc::VideoEncoder* CreateVideoEncoder(
6128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::VideoCodecType type) = 0;
6228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
6328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // Returns a list of supported codecs in order of preference.
6428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual const std::vector<VideoCodec>& codecs() const = 0;
6528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
6652cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org  // Returns true if encoders created by this factory of the given codec type
6752cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org  // will use internal camera sources, meaning that they don't require/expect
6852cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org  // frames to be delivered via webrtc::VideoEncoder::Encode. This flag is used
6952cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org  // as the internal_source parameter to
7052cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org  // webrtc::ViEExternalCodec::RegisterExternalSendCodec.
7152cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org  virtual bool EncoderTypeHasInternalSource(webrtc::VideoCodecType type) const {
7252cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org    return false;
7352cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org  }
7452cd828e1731266272e671020c353f5f89992a83pthatcher@webrtc.org
7528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) = 0;
7628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org};
7728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
7828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}  // namespace cricket
7928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
8028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#endif  // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENCODERFACTORY_H_
81