2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG (www.casparcg.com).
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
19 * Author: Robert Nagy, ronag89@gmail.com
\r
22 #include "../../stdafx.h"
\r
26 #include <common/except.h>
\r
27 #include <common/log.h>
\r
29 #include <boost/filesystem.hpp>
\r
33 #include <unordered_map>
\r
35 namespace caspar { namespace ffmpeg {
\r
37 std::map<std::string, std::string> read_flv_meta_info(const std::string& filename)
\r
39 std::map<std::string, std::string> values;
\r
41 if(boost::filesystem::path(filename).extension().string() != ".flv")
\r
46 if(!boost::filesystem::exists(filename))
\r
47 CASPAR_THROW_EXCEPTION(caspar_exception());
\r
49 std::fstream fileStream = std::fstream(filename, std::fstream::in);
\r
51 std::vector<char> bytes2(256);
\r
52 fileStream.read(bytes2.data(), bytes2.size());
\r
54 auto ptr = bytes2.data();
\r
58 if(std::string(ptr, ptr+10) == "onMetaData")
\r
62 for(int n = 0; n < 16; ++n)
\r
64 char name_size = *ptr++;
\r
69 auto name = std::string(ptr, ptr + name_size);
\r
72 char data_type = *ptr++;
\r
77 static_assert(sizeof(double) == 8, "");
\r
78 std::reverse(ptr, ptr+8);
\r
79 values[name] = boost::lexical_cast<std::string>(*(double*)(ptr));
\r
86 values[name] = boost::lexical_cast<std::string>(*ptr != 0);
\r
97 CASPAR_LOG_CURRENT_EXCEPTION();
\r