diff options
Diffstat (limited to 'httptnt')
| -rw-r--r-- | httptnt/resourceStreamer.ecpp | 37 | 
1 files changed, 23 insertions, 14 deletions
| diff --git a/httptnt/resourceStreamer.ecpp b/httptnt/resourceStreamer.ecpp index 2c64fed..96c4ea4 100644 --- a/httptnt/resourceStreamer.ecpp +++ b/httptnt/resourceStreamer.ecpp @@ -1,8 +1,8 @@ -<%args> -objectID; -int resourceID = 0; -</%args> -<%pre> +//<%args> +//objectID; +//int resourceID = 0; +//</%args> +//<%pre>  #include <string>  #include <stdint.h>  #include <limits> @@ -16,11 +16,11 @@ int resourceID = 0;  #include <tnt/http.h>  using namespace upnp; -</%pre> -<# +//</%pre> +//<#  int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string objectID, int resourceID) { -#> -<%cpp> +//#> +//<%cpp>    if(objectID.empty()){      reply.out() << "Object ID missing";      return HTTP_BAD_REQUEST; @@ -28,7 +28,7 @@ int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string object    cMediaServer* server = cMediaServer::GetInstance();    cMediaManager& manager = server->GetManager(); -  std::auto_ptr<cResourceStreamer> streamer(manager.GetResourceStreamer(objectID, resourceID)); +  boost::shared_ptr<cResourceStreamer> streamer(manager.GetResourceStreamer(objectID, resourceID));    if(!streamer.get()){      reply.out() << "Object ID not found or invalid"; @@ -49,6 +49,11 @@ int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string object    if(!request.isMethodHEAD()){ +    if(!streamer->Open()){ +      code = HTTP_INTERNAL_SERVER_ERROR; +      goto ret; +    } +      int offset = 0, length = std::numeric_limits<long>::max();      bool hasRange = false; @@ -66,7 +71,10 @@ int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string object          }        } -      streamer->Seek(offset, SEEK_SET); +      if(!streamer->Seek(offset, SEEK_SET)){ +        code = HTTP_INTERNAL_SERVER_ERROR; +        goto ret; +      }      }      char buffer[KB(16)]; @@ -97,9 +105,10 @@ int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string object    }    ret: +  streamer->Close();    //reply.out() << std::flush;    return code; -</%cpp> -<# +//</%cpp> +//<#  } -#> +//#> | 
