summaryrefslogtreecommitdiff
path: root/indra/newview/llvovolume.cpp
diff options
context:
space:
mode:
authorRick Pasetto <rick@lindenlab.com>2009-10-05 17:21:08 +0000
committerRick Pasetto <rick@lindenlab.com>2009-10-05 17:21:08 +0000
commit349eb393bc0666e323feff3b3a7eacab4f9bba84 (patch)
tree6b18e6c30d7ba6472561a1d3504739ad24aecf69 /indra/newview/llvovolume.cpp
parent3e29163b47719c55ef3e48adbc57a0ce733768e3 (diff)
DEV-40650: Refactor llmediadataresponder and llmediadatafetcher into a single reusable class
CC Review #7 (monroe) LLMediaDataResponder and LLMediaDataFetcher were helpful classes that interacted with each other, but they were not general enough to cleanly be used for all media service interaction. This change refactors these classes into one (in fact, it is closer to a complete rewrite): LLMediaDataClient. This class has the following design points: - You subclass from it when you want to specialize the responder, and then subclass from LLMediaDataClient::Responder if desired - It has a few inner classes: - LLMediaDataClient::Request, which now holds all of the data pertaining to a request, including retry counts - LLMediaDataClient::Responder, which is now the LLHTTPClient::Responder - LLMediaDataClient::PriorityQueue, which is now a STL priority_queue of Request objects. - LLMediaDataClient::QueueTimer, which is the timer that fires to peel off queue items - LLMediaDataClient::Responder::RetryTimer, which is the timer that is used when 503 errors are received. The encapsulation of these inner classes is a lot cleaner and better reflects the scope of their responsibilities. By and large, the logic hasn't really changed much. However, now there are two subclasses of LLMediaDataClient: one for the ObjectMedia cap and the other for the ObjectMediaNavigate cap. (I decided it was overkill to make three subclasses, one each for GET, UPDATE, and NAVIGATE, but we could still do that). LLVOVolume now instantiates both of these classes as statics (and destroys them on shutdown). They now have very simple API: - LLObjectMediaDataClient::fetchMedia(LLVOVolume*) fetches the media for the given object - LLObjectMediaDataClient::updateMedia(LLVOVolume*) sends an UPDATE of the media from the given object - LLObjectMediaNavigateClient::navigate(LLVOVolume*, U8 texture_index, const std::string &url) navigates the given face (texture_index) on the given object to the given url.
Diffstat (limited to 'indra/newview/llvovolume.cpp')
-rw-r--r--indra/newview/llvovolume.cpp53
1 files changed, 11 insertions, 42 deletions
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index e69779b2dc..583246c23e 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -46,7 +46,6 @@
#include "llvolumemessage.h"
#include "material_codes.h"
#include "message.h"
-#include "llmediadataresponder.h"
#include "llpluginclassmedia.h" // for code in the mediaEvent handler
#include "object_flags.h"
#include "llagentconstants.h"
@@ -69,7 +68,7 @@
#include "pipeline.h"
#include "llsdutil.h"
#include "llmediaentry.h"
-#include "llmediadatafetcher.h"
+#include "llmediadataclient.h"
#include "llagent.h"
const S32 MIN_QUIET_FRAMES_COALESCE = 30;
@@ -86,6 +85,8 @@ F32 LLVOVolume::sLODFactor = 1.f;
F32 LLVOVolume::sLODSlopDistanceFactor = 0.5f; //Changing this to zero, effectively disables the LOD transition slop
F32 LLVOVolume::sDistanceFactor = 1.0f;
S32 LLVOVolume::sNumLODChanges = 0;
+LLPointer<LLObjectMediaDataClient> LLVOVolume::sObjectMediaClient = NULL;
+LLPointer<LLObjectMediaNavigateClient> LLVOVolume::sObjectMediaNavigateClient = NULL;
static LLFastTimer::DeclareTimer FTM_GEN_TRIANGLES("Generate Triangles");
static LLFastTimer::DeclareTimer FTM_GEN_VOLUME("Generate Volumes");
@@ -133,13 +134,15 @@ LLVOVolume::~LLVOVolume()
// static
void LLVOVolume::initClass()
{
- LLMediaDataFetcher::initClass();
+ sObjectMediaClient = new LLObjectMediaDataClient();
+ sObjectMediaNavigateClient = new LLObjectMediaNavigateClient();
}
// static
void LLVOVolume::cleanupClass()
{
- LLMediaDataFetcher::cleanupClass();
+ sObjectMediaClient = NULL;
+ sObjectMediaNavigateClient = NULL;
}
U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
@@ -1621,7 +1624,7 @@ bool LLVOVolume::hasMedia() const
void LLVOVolume::requestMediaDataUpdate()
{
- LLMediaDataFetcher::fetchMedia(this);
+ sObjectMediaClient->fetchMedia(this);
}
void LLVOVolume::cleanUpMediaImpls()
@@ -1752,21 +1755,7 @@ void LLVOVolume::mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin,
llinfos << "broadcasting navigate with URI " << new_location << llendl;
- // Post the navigate to the cap
- std::string cap = getRegion()->getCapability("ObjectMediaNavigate");
- if(cap.empty())
- {
- // XXX *TODO: deal with no cap! It may happen! (retry?)
- LL_WARNS("Media") << "Can't broadcast navigate event -- ObjectMediaNavigate cap is not available" << LL_ENDL;
- return;
- }
-
- // If we got here, the cap is available. Index through all faces that have this media and send the navigate message.
- LLSD sd;
- sd["object_id"] = mID;
- sd["current_url"] = new_location;
- sd["texture_index"] = face_index;
- LLHTTPClient::post(cap, sd, new LLMediaDataResponder("ObjectMediaNavigate", sd, this));
+ sObjectMediaNavigateClient->navigate(this, face_index, new_location);
}
}
break;
@@ -1790,29 +1779,9 @@ void LLVOVolume::mediaEvent(LLViewerMediaImpl *impl, LLPluginClassMedia* plugin,
}
-void LLVOVolume::sendMediaDataUpdate() const
+void LLVOVolume::sendMediaDataUpdate()
{
- std::string url = getRegion()->getCapability("ObjectMedia");
- if (!url.empty())
- {
- LLSD sd_payload;
- sd_payload["verb"] = "UPDATE";
- sd_payload[LLTextureEntry::OBJECT_ID_KEY] = mID;
- LLSD object_media_data;
- for (int i=0; i < getNumTEs(); i++) {
- LLTextureEntry *texture_entry = getTE(i);
- llassert((texture_entry->getMediaData() != NULL) == texture_entry->hasMedia());
- const LLSD &media_data =
- (texture_entry->getMediaData() == NULL) ? LLSD() : texture_entry->getMediaData()->asLLSD();
- object_media_data.append(media_data);
- }
- sd_payload[LLTextureEntry::OBJECT_MEDIA_DATA_KEY] = object_media_data;
-
- llinfos << "Sending media data: " << getID() << " " << ll_pretty_print_sd(sd_payload) << llendl;
-
- LLHTTPClient::post(url, sd_payload, new LLMediaDataResponder("ObjectMedia", sd_payload, this));
- }
- // XXX *TODO: deal with no cap! It may happen! (retry?)
+ sObjectMediaClient->updateMedia(this);
}
void LLVOVolume::removeMediaImpl(S32 texture_index)