PageRenderTime 75ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/CSipSimple/jni/webrtc/sources/video_engine/vie_frame_provider_base.h

https://bitbucket.org/bohlooli/csipsimple
C Header | 102 lines | 55 code | 23 blank | 24 comment | 0 complexity | 5e16a8b65e13619b2e2a8c36ec0defa5 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, LGPL-3.0, GPL-3.0, GPL-2.0
  1. /*
  2. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  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
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef WEBRTC_VIDEO_ENGINE_VIE_FRAME_PROVIDER_BASE_H_
  11. #define WEBRTC_VIDEO_ENGINE_VIE_FRAME_PROVIDER_BASE_H_
  12. #include <vector>
  13. #include "common_types.h" // NOLINT
  14. #include "system_wrappers/interface/scoped_ptr.h"
  15. #include "typedefs.h" // NOLINT
  16. namespace webrtc {
  17. class CriticalSectionWrapper;
  18. class VideoEncoder;
  19. class VideoFrame;
  20. // ViEFrameCallback shall be implemented by all classes receiving frames from a
  21. // frame provider.
  22. class ViEFrameCallback {
  23. public:
  24. virtual void DeliverFrame(int id,
  25. VideoFrame* video_frame,
  26. int num_csrcs = 0,
  27. const WebRtc_UWord32 CSRC[kRtpCsrcSize] = NULL) = 0;
  28. // The capture delay has changed from the provider. |frame_delay| is given in
  29. // ms.
  30. virtual void DelayChanged(int id, int frame_delay) = 0;
  31. // Get the width, height and frame rate preferred by this observer.
  32. virtual int GetPreferedFrameSettings(int* width,
  33. int* height,
  34. int* frame_rate) = 0;
  35. // ProviderDestroyed is called when the frame is about to be destroyed. There
  36. // must not be any more calls to the frame provider after this.
  37. virtual void ProviderDestroyed(int id) = 0;
  38. virtual ~ViEFrameCallback() {}
  39. };
  40. // ViEFrameProviderBase is a base class that will deliver frames to all
  41. // registered ViEFrameCallbacks.
  42. class ViEFrameProviderBase {
  43. public:
  44. ViEFrameProviderBase(int Id, int engine_id);
  45. virtual ~ViEFrameProviderBase();
  46. // Returns the frame provider id.
  47. int Id();
  48. // Register frame callbacks, i.e. a receiver of the captured frame.
  49. virtual int RegisterFrameCallback(int observer_id,
  50. ViEFrameCallback* callback_object);
  51. virtual int DeregisterFrameCallback(const ViEFrameCallback* callback_object);
  52. virtual bool IsFrameCallbackRegistered(
  53. const ViEFrameCallback* callback_object);
  54. int NumberOfRegisteredFrameCallbacks();
  55. // FrameCallbackChanged
  56. // Inherited classes should check for new frame_settings and reconfigure
  57. // output if possible.
  58. virtual int FrameCallbackChanged() = 0;
  59. protected:
  60. void DeliverFrame(VideoFrame* video_frame,
  61. int num_csrcs = 0,
  62. const WebRtc_UWord32 CSRC[kRtpCsrcSize] = NULL);
  63. void SetFrameDelay(int frame_delay);
  64. int FrameDelay();
  65. int GetBestFormat(int* best_width,
  66. int* best_height,
  67. int* best_frame_rate);
  68. int id_;
  69. int engine_id_;
  70. // Frame callbacks.
  71. typedef std::vector<ViEFrameCallback*> FrameCallbacks;
  72. FrameCallbacks frame_callbacks_;
  73. scoped_ptr<CriticalSectionWrapper> provider_cs_;
  74. private:
  75. scoped_ptr<VideoFrame> extra_frame_;
  76. int frame_delay_;
  77. };
  78. } // namespace webrtc
  79. #endif // WEBRTC_VIDEO_ENGINE_VIE_FRAME_PROVIDER_BASE_H_