llviewerparcelmedia.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * @file llviewerparcelmedia.h
  3. * @brief Handlers for multimedia on a per-parcel basis
  4. *
  5. * $LicenseInfo:firstyear=2007&license=viewergpl$
  6. *
  7. * Copyright (c) 2007-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LLVIEWERPARCELMEDIA_H
  33. #define LLVIEWERPARCELMEDIA_H
  34. #include "llaudioengine.h"
  35. #include "llviewermedia.h"
  36. class LLMessageSystem;
  37. class LLParcel;
  38. class LLViewerParcelMediaNavigationObserver;
  39. // This class understands land parcels, network traffic, LSL media transport
  40. // commands, and talks to the LLViewerMedia class to actually do playback.
  41. class LLViewerParcelMedia : public LLViewerMediaObserver
  42. {
  43. protected:
  44. LOG_CLASS(LLViewerParcelMedia);
  45. public:
  46. static void initClass();
  47. static void cleanupClass();
  48. // Called when the agent's parcel has a new URL, or the agent has walked on
  49. // to a new parcel with media.
  50. static void update(LLParcel* parcel);
  51. // play the parcel music stream
  52. static void playStreamingMusic(LLParcel* parcel, bool filter = true);
  53. // User clicked play button in music controls
  54. // Can be used as a callback in menus
  55. static void playMusic(void* userdata = NULL);
  56. // User clicked pause button in music controls
  57. // Can be used as a callback in menus
  58. static void pauseMusic(void* userdata = NULL);
  59. // stop the parcel music stream
  60. static void stopStreamingMusic();
  61. // User clicked stop button in music controls
  62. // Can be used as a callback in menus
  63. static void stopMusic(void* userdata = NULL);
  64. static bool parcelMusicPlaying() { return sParcelMusicState == PLAYING; }
  65. static bool parcelMusicPaused() { return sParcelMusicState == PAUSED; }
  66. static bool parcelMusicStopped() { return sParcelMusicState == STOPPED; }
  67. // play the parcel media stream
  68. static void playMedia(LLParcel* parcel, bool filter = true);
  69. // User clicked play button in media controls
  70. // Can be used as a callback in menus
  71. static void play(void* userdata = NULL);
  72. // User clicked stop button in media controls
  73. // Can be used as a callback in menus
  74. static void stop(void* userdata = NULL);
  75. // user clicked pause button in media controls
  76. // Can be used as a callback in menus
  77. static void pause(void* userdata = NULL);
  78. // restart after pause - no need for all the setup
  79. static void start();
  80. static void focus(bool focus);
  81. // Jump to timecode time
  82. static void seek(F32 time);
  83. static LLViewerMediaImpl::EMediaStatus getStatus();
  84. static std::string getMimeType();
  85. static std::string getURL();
  86. static std::string getName();
  87. static std::string getParcelAudioURL();
  88. // These are just helper functions for the convenience of others working
  89. // with media
  90. LL_INLINE static viewer_media_t getParcelMedia() { return sMediaImpl; }
  91. LL_INLINE static bool hasParcelMedia() { return !getURL().empty(); }
  92. LL_INLINE static bool hasParcelAudio() { return !getParcelAudioURL().empty(); }
  93. LL_INLINE static bool isParcelMediaPlaying() { return sMediaImpl.notNull() &&
  94. !getURL().empty() &&
  95. sMediaImpl->hasMedia(); }
  96. static bool isParcelAudioPlaying() { return gAudiop && !getParcelAudioURL().empty() &&
  97. gAudiop->isInternetStreamPlaying(); }
  98. static void processParcelMediaCommandMessage(LLMessageSystem* msg, void**);
  99. static void processParcelMediaUpdate(LLMessageSystem* msg, void**);
  100. static void sendMediaNavigateMessage(const std::string& url);
  101. // inherited from LLViewerMediaObserver
  102. virtual void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event);
  103. static void registerStreamingAudioPlugin();
  104. public:
  105. static S32 sMediaParcelLocalID;
  106. static LLUUID sMediaRegionID;
  107. // HACK: this will change with Media on a Prim
  108. static viewer_media_t sMediaImpl;
  109. private:
  110. enum { STOPPED = 0, PLAYING = 1, PAUSED = 2 };
  111. static S32 sParcelMusicState;
  112. };
  113. class LLViewerParcelMediaNavigationObserver
  114. {
  115. public:
  116. std::string mCurrentURL;
  117. bool mFromMessage;
  118. //void onNavigateComplete(const EventType& event_in);
  119. };
  120. #endif