]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/producer/util/flv.cpp
set svn:eol-style native on .h and .cpp files
[casparcg] / modules / ffmpeg / producer / util / flv.cpp
index 15a6fa3525da9083f8b0b7f7b9897739b79da0a2..72445136a6a2a63f61d32c5ef4c20cc569396da6 100644 (file)
-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#include "../../stdafx.h"\r
-\r
-#include "flv.h"\r
-\r
-#include <common/except.h>\r
-#include <common/log.h>\r
-\r
-#include <boost/filesystem.hpp>\r
-\r
-#include <iostream>\r
-\r
-#include <unordered_map>\r
-\r
-namespace caspar { namespace ffmpeg {\r
-       \r
-std::map<std::string, std::string> read_flv_meta_info(const std::string& filename)\r
-{\r
-       std::map<std::string, std::string>  values;\r
-\r
-       if(boost::filesystem::path(filename).extension().string() != ".flv")\r
-               return values;\r
-       \r
-       try\r
-       {\r
-               if(!boost::filesystem::exists(filename))\r
-                       CASPAR_THROW_EXCEPTION(caspar_exception());\r
-       \r
-               std::fstream fileStream = std::fstream(filename, std::fstream::in);\r
-               \r
-               std::vector<char> bytes2(256);\r
-               fileStream.read(bytes2.data(), bytes2.size());\r
-\r
-               auto ptr = bytes2.data();\r
-               \r
-               ptr += 27;\r
-                                               \r
-               if(std::string(ptr, ptr+10) == "onMetaData")\r
-               {\r
-                       ptr += 16;\r
-\r
-                       for(int n = 0; n < 16; ++n)\r
-                       {\r
-                               char name_size = *ptr++;\r
-\r
-                               if(name_size == 0)\r
-                                       break;\r
-\r
-                               auto name = std::string(ptr, ptr + name_size);\r
-                               ptr += name_size;\r
-\r
-                               char data_type = *ptr++;\r
-                               switch(data_type)\r
-                               {\r
-                               case 0: // double\r
-                                       {\r
-                                               static_assert(sizeof(double) == 8, "");\r
-                                               std::reverse(ptr, ptr+8);\r
-                                               values[name] = boost::lexical_cast<std::string>(*(double*)(ptr));\r
-                                               ptr += 9;\r
-\r
-                                               break;\r
-                                       }\r
-                               case 1: // bool\r
-                                       {\r
-                                               values[name] = boost::lexical_cast<std::string>(*ptr != 0);\r
-                                               ptr += 2;\r
-\r
-                                               break;\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-       catch(...)\r
-       {\r
-               CASPAR_LOG_CURRENT_EXCEPTION();\r
-       }\r
-\r
-    return values;\r
-}\r
-\r
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#include "../../stdafx.h"
+
+#include "flv.h"
+
+#include <common/except.h>
+#include <common/log.h>
+
+#include <boost/filesystem.hpp>
+
+#include <iostream>
+
+#include <unordered_map>
+
+namespace caspar { namespace ffmpeg {
+       
+std::map<std::string, std::string> read_flv_meta_info(const std::string& filename)
+{
+       std::map<std::string, std::string>  values;
+
+       if(boost::filesystem::path(filename).extension().string() != ".flv")
+               return values;
+       
+       try
+       {
+               if(!boost::filesystem::exists(filename))
+                       CASPAR_THROW_EXCEPTION(caspar_exception());
+       
+               std::fstream fileStream = std::fstream(filename, std::fstream::in);
+               
+               std::vector<char> bytes2(256);
+               fileStream.read(bytes2.data(), bytes2.size());
+
+               auto ptr = bytes2.data();
+               
+               ptr += 27;
+                                               
+               if(std::string(ptr, ptr+10) == "onMetaData")
+               {
+                       ptr += 16;
+
+                       for(int n = 0; n < 16; ++n)
+                       {
+                               char name_size = *ptr++;
+
+                               if(name_size == 0)
+                                       break;
+
+                               auto name = std::string(ptr, ptr + name_size);
+                               ptr += name_size;
+
+                               char data_type = *ptr++;
+                               switch(data_type)
+                               {
+                               case 0: // double
+                                       {
+                                               static_assert(sizeof(double) == 8, "");
+                                               std::reverse(ptr, ptr+8);
+                                               values[name] = boost::lexical_cast<std::string>(*(double*)(ptr));
+                                               ptr += 9;
+
+                                               break;
+                                       }
+                               case 1: // bool
+                                       {
+                                               values[name] = boost::lexical_cast<std::string>(*ptr != 0);
+                                               ptr += 2;
+
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       }
+       catch(...)
+       {
+               CASPAR_LOG_CURRENT_EXCEPTION();
+       }
+
+    return values;
+}
+
 }}
\ No newline at end of file