diff OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1950:533ff46e944b

return a single raw frame from DICOM videos
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 05 Apr 2016 11:07:02 +0200
parents cda5b0ab4ce5
children f11e5d200c04
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Tue Apr 05 10:30:17 2016 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Tue Apr 05 11:07:02 2016 +0200
@@ -236,28 +236,22 @@
   
   static void ListFrames(RestApiGetCall& call)
   {
-    Json::Value instance;
-    if (OrthancRestApi::GetIndex(call).LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance))
-    {
-      unsigned int numberOfFrames = 1;
+    std::string publicId = call.GetUriComponent("id", "");
 
-      try
-      {
-        Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"];
-        numberOfFrames = boost::lexical_cast<unsigned int>(tmp.asString());
-      }
-      catch (...)
-      {
-      }
-
-      Json::Value result = Json::arrayValue;
-      for (unsigned int i = 0; i < numberOfFrames; i++)
-      {
-        result.append(i);
-      }
-
-      call.GetOutput().AnswerJson(result);
+    unsigned int numberOfFrames;
+      
+    {
+      ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), publicId);
+      numberOfFrames = locker.GetDicom().GetFramesCount();
     }
+    
+    Json::Value result = Json::arrayValue;
+    for (unsigned int i = 0; i < numberOfFrames; i++)
+    {
+      result.append(i);
+    }
+    
+    call.GetOutput().AnswerJson(result);
   }