/wrt-plugins-common/src/modules/tizen/MMPlayer/MMPlayer.h

https://review.tizen.org/git/ · C Header · 138 lines · 62 code · 20 blank · 56 comment · 0 complexity · cfad46068a60ed9b79549048579c1856 MD5 · raw file

  1. /*
  2. * Copyright (c) 2011 Samsung Electronics Co., Ltd 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. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef WRTDEVICEAPIS_MMPLAYER_MMPLAYER_H_
  17. #define WRTDEVICEAPIS_MMPLAYER_MMPLAYER_H_
  18. #include <mmf/mm.h>
  19. #include <mm_player.h>
  20. #include <dpl/shared_ptr.h>
  21. #include <dpl/mutex.h>
  22. #include <MMPlayer/IMMPlayer.h>
  23. #include <MMPlayer/MMPlayerFactory.h>
  24. #include <MMPlayer/EventOnStateChange.h>
  25. namespace WrtDeviceApis {
  26. namespace MMPlayer {
  27. /**
  28. * Event to send from callback when end of stream will be reported -> mm_player_stop should be executed
  29. */
  30. class EventOnEOS : public Commons::ListenerEvent<EventOnEOS>
  31. {
  32. };
  33. typedef DPL::SharedPtr<EventOnEOS> EventOnEOSPtr;
  34. typedef Commons::ListenerEventEmitter<EventOnEOS> EventOnEOSEmitter;
  35. typedef DPL::SharedPtr<EventOnEOSEmitter> EventOnEOSEmitterPtr;
  36. class MMPlayer :
  37. public Api::IMMPlayer,
  38. public Commons::EventListener<EventOnEOS>
  39. {
  40. friend class Api::MMPlayerFactory;
  41. public:
  42. typedef enum
  43. {
  44. STATE_OPENED,
  45. STATE_STOPPED,
  46. STATE_PLAYING,
  47. STATE_PAUSED,
  48. STATE_COMPLETED,
  49. STATE_UNDEFINED
  50. } MMPLAYER_STATES;
  51. private:
  52. MMHandleType m_player;
  53. MMPLAYER_STATES m_currentState;
  54. unsigned int m_repeatTimes;
  55. /**
  56. * MMPlayer constructor
  57. * \exception Commons::PlatformException when platform error occurs
  58. */
  59. explicit MMPlayer();
  60. public:
  61. /**
  62. * MMPlayer destructor
  63. */
  64. virtual ~MMPlayer();
  65. /**
  66. * Gets handler to platform player type
  67. */
  68. virtual MMHandleType getHandler() const;
  69. /**
  70. * @See Api::MMPlayer::IMMPlayer::setEmitter
  71. */
  72. virtual void setEmitter(
  73. const Api::EventOnStateChangeEmitterPtr& emitter);
  74. /**
  75. * @See Api::MMPlayer::IMMPlayer::getEmitter
  76. */
  77. Api::EventOnStateChangeEmitterPtr getEmitter();
  78. /**
  79. * @See Api::MMPlayer::IMMPlayer::clearEmitter
  80. */
  81. virtual void clearEmitter();
  82. /**
  83. * Gets player state
  84. */
  85. virtual MMPlayerStateType getState() const;
  86. /**
  87. * Used to recieve EventOnEOS
  88. */
  89. virtual void onAnswerReceived(const EventOnEOSPtr& event);
  90. virtual unsigned int getRepeatTimes() const;
  91. virtual void setRepeatTimes(unsigned int count);
  92. private:
  93. /**
  94. * Callback method called by platform when player state changes.
  95. * @param message Platform message
  96. * @param param Platform parameter
  97. * @param data User data.
  98. */
  99. static int onStateChange(int message,
  100. void* param,
  101. void* data);
  102. /**
  103. * Initialize player
  104. * @throw Commons::PlatformException when platform error occures
  105. */
  106. void init();
  107. /**
  108. * Finalize player
  109. */
  110. void finalize();
  111. DPL::Mutex m_emitterMtx;
  112. Api::EventOnStateChangeEmitterPtr m_onStateChangeEmitter;
  113. EventOnEOSEmitterPtr m_onEOSEmitter;
  114. };
  115. typedef DPL::SharedPtr<MMPlayer> MMPlayerPtr;
  116. }
  117. }
  118. #endif // WRTDEVICEAPIS_MMPLAYER_MMPLAYER_H_