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/exception/exceptions.h>
\r
28 #include <boost/filesystem.hpp>
\r
32 #include <unordered_map>
\r
34 namespace caspar { namespace ffmpeg {
\r
36 std::map<std::string, std::string> read_flv_meta_info(const std::string& filename)
\r
38 std::map<std::string, std::string> values;
\r
40 if(boost::filesystem2::path(filename).extension() != ".flv")
\r
45 if(!boost::filesystem2::exists(filename))
\r
46 BOOST_THROW_EXCEPTION(caspar_exception());
\r
48 std::fstream fileStream = std::fstream(filename, std::fstream::in);
\r
50 std::vector<char> bytes2(256);
\r
51 fileStream.read(bytes2.data(), bytes2.size());
\r
53 auto ptr = bytes2.data();
\r
57 if(std::string(ptr, ptr+10) == "onMetaData")
\r
61 for(int n = 0; n < 16; ++n)
\r
63 char name_size = *ptr++;
\r
68 auto name = std::string(ptr, ptr + name_size);
\r
71 char data_type = *ptr++;
\r
76 static_assert(sizeof(double) == 8, "");
\r
77 std::reverse(ptr, ptr+8);
\r
78 values[name] = boost::lexical_cast<std::string>(*(double*)(ptr));
\r
85 values[name] = boost::lexical_cast<std::string>(*ptr != 0);
\r
96 CASPAR_LOG_CURRENT_EXCEPTION();
\r