aboutsummaryrefslogtreecommitdiff
path: root/modules/pdp_mp4config.cpp
blob: 3fbcb9f2d9973a5a5f154f92256b4d3705d5a16f (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 * 
 * The Original Code is MPEG4IP.
 * 
 * The Initial Developer of the Original Code is Cisco Systems Inc.
 * Portions created by Cisco Systems Inc. are
 * Copyright (C) Cisco Systems Inc. 2000, 2001.  All Rights Reserved.
 * 
 * Contributor(s): 
 *		Dave Mackie		dmackie@cisco.com
 *		Bill May 		wmay@cisco.com
 *
 * Adapted for PD/PDP by Yves Degoyon (ydegoyon@free.fr)
 */

#include "pdp_mp4config.h"

CLiveConfig::CLiveConfig(
	SConfigVariable* variables, 
	config_index_t numVariables, 
	const char* defaultFileName)
: CConfigSet(variables, numVariables, defaultFileName) 
{
	m_appAutomatic = false;
	m_videoEncode = true;
	m_videoMaxWidth = 768;
	m_videoMaxHeight = 576;
	m_videoNeedRgbToYuv = false;
	m_videoMpeg4ConfigLength = 0;
	m_videoMpeg4Config = NULL;
	m_videoMaxVopSize = 128 * 1024;
	m_audioEncode = true;
}

CLiveConfig::~CLiveConfig()
{
	CHECK_AND_FREE(m_videoMpeg4Config);
}

// recalculate derived values
void CLiveConfig::Update() 
{
	UpdateVideo();
	UpdateAudio();
}

void CLiveConfig::UpdateVideo() 
{
	m_videoEncode = true;

	CalculateVideoFrameSize();

	GenerateMpeg4VideoConfig(this);
}

void CLiveConfig::UpdateFileHistory(const char* fileName)
{
}

void CLiveConfig::CalculateVideoFrameSize()
{
	u_int16_t frameHeight;
	float aspectRatio = GetFloatValue(CONFIG_VIDEO_ASPECT_RATIO);

	// crop video to appropriate aspect ratio modulo 16 pixels
	if ((aspectRatio - VIDEO_STD_ASPECT_RATIO) < 0.1) {
		frameHeight = GetIntegerValue(CONFIG_VIDEO_RAW_HEIGHT);
	} else {
		frameHeight = (u_int16_t)(
			(float)GetIntegerValue(CONFIG_VIDEO_RAW_WIDTH) 
			/ aspectRatio);

		if ((frameHeight % 16) != 0) {
			frameHeight += 16 - (frameHeight % 16);
		}

		if (frameHeight > GetIntegerValue(CONFIG_VIDEO_RAW_HEIGHT)) {
			// OPTION might be better to insert black lines 
			// to pad image but for now we crop down
			frameHeight = GetIntegerValue(CONFIG_VIDEO_RAW_HEIGHT);
			if ((frameHeight % 16) != 0) {
				frameHeight -= (frameHeight % 16);
			}
		}
	}

	m_videoWidth = GetIntegerValue(CONFIG_VIDEO_RAW_WIDTH);
	m_videoHeight = frameHeight;

	m_ySize = m_videoWidth * m_videoHeight;
	m_uvSize = m_ySize / 4;
	m_yuvSize = (m_ySize * 3) / 2;
}

void CLiveConfig::UpdateAudio() 
{
	m_audioEncode = true;
}

void CLiveConfig::UpdateRecord()
{
}

bool CLiveConfig::IsOneSource()
{
   return true;
}

bool CLiveConfig::IsCaptureVideoSource()
{
   return false;
}

bool CLiveConfig::IsCaptureAudioSource()
{
   return false;
}

bool CLiveConfig::IsFileVideoSource()
{
   return false;
}

bool CLiveConfig::IsFileAudioSource()
{
   return false;
}