CuteLogger
Fast and simple logging solution for Qt based applications
sa3d.h
1 #pragma once
2 /*****************************************************************************
3  *
4  * Copyright 2016 Varol Okan. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  ****************************************************************************/
19 
20 /* MPEG SA3D Box processing class
21  * This class enables the injection of SA2D MPEG-4. The SA3D box
22  * specification as outlned in
23  * https://github.com/google/spatial-media/docs/spatial-audio-rfc.md
24  */
25 
26 #include <stdint.h>
27 
28 #include <fstream>
29 #include <vector>
30 #include <map>
31 
32 #include "box.h"
33 
34 class SA3DBox : public Box
35 {
36  SA3DBox ( ) { };
37  public:
38  enum ePosition { None };
39 
40  SA3DBox ( Box * );
41  virtual ~SA3DBox ( );
42 
43  // Loads the SA3D box located at position pos in a mp4 file.
44  static Box *load ( std::fstream &fs, uint32_t iPos, uint32_t iEnd );
45 
46  static Box *create ( int32_t iNumChannels, AudioMetadata & );
47 
48  void save ( std::fstream &fsIn, std::fstream &fsOut );
49  const char *ambisonic_type_name ( );
50  const char *ambisonic_channel_ordering_name ( );
51  const char *ambisonic_normalization_name ( );
52  void print_box ( );
53 
54  std::string get_metadata_string ( );
55 
56  private:
57  std::string mapToString ( );
58 
59  public:
60  std::map<std::string, int32_t> m_AmbisonicTypes;
61  std::map<std::string, int32_t> m_AmbisonicOrderings;
62  std::map<std::string, int32_t> m_AmbisonicNormalizations;
63 
64 // int32_t m_iPosition;
65  uint8_t m_iVersion;
66  uint8_t m_iAmbisonicType;
67  uint32_t m_iAmbisonicOrder;
68  uint8_t m_iAmbisonicChannelOrdering;
69  uint8_t m_iAmbisonicNormalization;
70  uint32_t m_iNumChannels;
71  std::vector<uint32_t> m_ChannelMap;
72 };
73