File: audio.h

package info (click to toggle)
vdr-plugin-markad 4.2.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,084 kB
  • sloc: cpp: 22,441; python: 613; makefile: 270; sh: 95
file content (95 lines) | stat: -rw-r--r-- 2,737 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * audio.h: A program for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#ifndef __audio_h_
#define __audio_h_

#include "global.h"
#include "debug.h"
#include "index.h"
#include "decoder.h"
#include "criteria.h"



/**
 *  detect audio channel changes and set channel marks
 */
class cAudio {
public:
    /**
     *  store maContext and recordingIndex for future use in this class
     *  @param decoderParam   pointer to decoder
     *  @param indexParam     recording index
     *  @param criteriaParam  analyse criteria
     */
    explicit cAudio(cDecoder *decoderParam, cIndex *indexParam, cCriteria *criteriaParam);
    ~cAudio();

    /**
     *  detect audio based marks
     */
    sMarkAdMarks *Detect();

private:
    /**
     * MP2 stream silence
     */
    typedef struct sAudioMP2Silence {
        int startPacketNumber = -1;    //!< start packet number
        //!<
        int64_t startAudioPTS = -1;    //!< start PTS of decoded audio frame
        //!<
        int64_t startVideoPTS = -1;    //!< start PTS of nearest video packet
        //!<
        int stopPacketNumber  = -1;    //!< stop packet number
        //!<
        int64_t stopAudioPTS  = -1;    //!< stop PTS of decoded audio frame
        //!<
        int64_t stopVideoPTS  = -1;    //!< stop PTS of nearest video packet
        //!<
    } sAudioMP2Silence;

    /**
     *  set channel change marks
     */
    void ChannelChange();

    /**
     * detect silence marks
     */
    void Silence();

    /**
     *  reset audio marks array
     */
    void ResetMarks();

    /**
     *  add a new mark ti mark array
     *  @param type           mark type (MT_CHANNELSTART or MT_CHANNELSTOP)
     *  @param packetNumber   packet number of the mark
     *  @param framePTS       PTS of decoded frame
     *  @param channelsBefore number of channels before change
     *  @param channelsAfter  number of channels after change
     */
    void AddMark(const int type, const int packetNumber, const int64_t framePTS, const int channelsBefore, const int channelsAfter);

    cDecoder *decoder              = nullptr;                //!< pointer to decoder
    //!<
    cIndex *index                  = nullptr;                //!< pointer to index
    //!<
    cCriteria *criteria            = nullptr;                //!< pointer to analyse criteria
    //!<
    int channelCountBefore         = 0;                      //!< AC3 channel count of frame before
    //!<
    sMarkAdMarks audioMarks        = {};                     //!< array of marks to add to list
    //!<
    sAudioMP2Silence audioMP2Silence   = {};                       //!< start/stop of silence
    //!<
};
#endif