AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DataProperties.cpp
Go to the documentation of this file.
1 #include "DataProperties.hpp"
2 
4 
5 extern "C" {
6 #include <libavcodec/avcodec.h>
7 }
8 
9 #include <bitset>
10 
11 namespace avtranscoder
12 {
13 
15 {
16  AVPacket pkt;
17  av_init_packet(&pkt);
18 
19  bool detection = false;
20 
21  while(!av_read_frame(const_cast<AVFormatContext*>(_formatContext), &pkt))
22  {
23  if(pkt.stream_index == (int)_streamIndex)
24  {
25  LOG_DEBUG("DataProperties - start detect packet");
26 
27  size_t offset = 0;
28  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
29  offset++;
30  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
31  offset++;
32  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
33  offset++;
34  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
35  offset++;
36  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
37  offset++;
38  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
39  offset++;
40  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
41  offset++;
42  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
43  offset++;
44  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
45  offset++;
46  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
47  offset++;
48  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
49  offset++;
50  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
51  offset++;
52  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
53  offset++;
54  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
55  offset++;
56  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
57  offset++;
58  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
59  offset++;
60  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
61  offset++;
62  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
63  offset++;
64  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
65  offset++;
66  LOG_DEBUG(offset << " - " << (int)pkt.data[offset] << " | " << std::bitset<8>(pkt.data[offset]))
67  offset++;
68 
69  unsigned short numberOfLines = (unsigned int)(pkt.data[0] << 8) + pkt.data[1];
70 
71  LOG_DEBUG("DataProperties - number of lines " << numberOfLines)
72 
73  detection = true;
74  }
75 
76  av_free_packet(&pkt);
77 
78  if(detection)
79  break;
80  }
81 }
82 
83 std::ostream& operator<<(std::ostream& flux, const DataProperties& dataProperties)
84 {
85  flux << detail::separator << " Data stream " << detail::separator << std::endl;
86 
87  PropertyVector properties = dataProperties.asVector();
88  for(PropertyVector::iterator it = properties.begin(); it != properties.end(); ++it)
89  {
90  flux << std::setw(detail::keyWidth) << it->first << ": " << it->second << std::endl;
91  }
92 
93  return flux;
94 }
95 }
std::vector< std::pair< std::string, std::string > > PropertyVector
PropertyVector is a vector of pair, because the order of properties matters to us.
Definition: util.hpp:23
const AVFormatContext * _formatContext
Has link (no ownership)
const size_t keyWidth
Definition: util.hpp:32
const std::string separator
Definition: util.hpp:33
#define LOG_DEBUG(...)
Definition: log.hpp:17
std::ostream & operator<<(std::ostream &flux, const InputFile &input)
Definition: InputFile.cpp:171
PropertyVector asVector() const
Same data with a specific order.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy