discard_frame.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*************************************************************************
  2. * Copyright (C) [2019] by Cambricon, Inc. All rights reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. * THE SOFTWARE.
  19. *************************************************************************/
  20. #ifndef MODULES_Discard_frame_HPP_
  21. #define MODULES_Discard_frame_HPP_
  22. /**
  23. * This file contains a declaration of struct DiscardFrame
  24. */
  25. #include <cmath>
  26. #include <memory>
  27. #include <string>
  28. #include <vector>
  29. #include "cnstream_frame.hpp"
  30. #include "cnstream_module.hpp"
  31. namespace cnstream {
  32. /**
  33. * @brief discard frame every n frames
  34. */
  35. class DiscardFrame : public Module, public ModuleCreator<DiscardFrame> {
  36. public:
  37. /**
  38. * @brief Generate DiscardFrame
  39. *
  40. * @param Name : Module name
  41. *
  42. * @return None
  43. */
  44. explicit DiscardFrame(const std::string& name);
  45. /**
  46. * @brief Called by pipeline when pipeline start.
  47. *
  48. * @param paramSet:
  49. * @verbatim
  50. * discard_interval:discard_interval
  51. * @endverbatim
  52. *
  53. * @return if module open succeed
  54. */
  55. bool Open(ModuleParamSet paramSet) override;
  56. /**
  57. * @brief Called by pipeline when pipeline end.
  58. */
  59. void Close() override;
  60. /**
  61. * @brief Do for each frame
  62. *
  63. * @param data : Pointer to the frame info
  64. *
  65. * @return whether process will discard frame
  66. * @retval 0: donot discard frame
  67. * @retval 1: discard frame
  68. *
  69. */
  70. int Process(std::shared_ptr<CNFrameInfo> data) override;
  71. /**
  72. * @brief Check ParamSet for a module.
  73. *
  74. * @param paramSet Parameters for this module.
  75. *
  76. * @return Returns true if this API run successfully. Otherwise, returns false.
  77. */
  78. bool CheckParamSet(const ModuleParamSet& paramSet) const override;
  79. virtual ~DiscardFrame();
  80. private:
  81. int frame_Mod = 0;
  82. }; // class DiscardFrame
  83. } // namespace cnstream
  84. #endif