Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bc871c94
authored
Nov 13, 2014
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add bitrate to MediaFormat
parent
4460b7c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
View file @
bc871c94
...
@@ -46,6 +46,8 @@ public class MediaFormat {
...
@@ -46,6 +46,8 @@ public class MediaFormat {
public
final
int
channelCount
;
public
final
int
channelCount
;
public
final
int
sampleRate
;
public
final
int
sampleRate
;
public
final
int
bitrate
;
private
int
maxWidth
;
private
int
maxWidth
;
private
int
maxHeight
;
private
int
maxHeight
;
...
@@ -69,13 +71,19 @@ public class MediaFormat {
...
@@ -69,13 +71,19 @@ public class MediaFormat {
public
static
MediaFormat
createVideoFormat
(
String
mimeType
,
int
maxInputSize
,
int
width
,
public
static
MediaFormat
createVideoFormat
(
String
mimeType
,
int
maxInputSize
,
int
width
,
int
height
,
float
pixelWidthHeightRatio
,
List
<
byte
[]>
initializationData
)
{
int
height
,
float
pixelWidthHeightRatio
,
List
<
byte
[]>
initializationData
)
{
return
new
MediaFormat
(
mimeType
,
maxInputSize
,
width
,
height
,
pixelWidthHeightRatio
,
NO_VALUE
,
return
new
MediaFormat
(
mimeType
,
maxInputSize
,
width
,
height
,
pixelWidthHeightRatio
,
NO_VALUE
,
NO_VALUE
,
initializationData
);
NO_VALUE
,
NO_VALUE
,
initializationData
);
}
}
public
static
MediaFormat
createAudioFormat
(
String
mimeType
,
int
maxInputSize
,
int
channelCount
,
public
static
MediaFormat
createAudioFormat
(
String
mimeType
,
int
maxInputSize
,
int
channelCount
,
int
sampleRate
,
List
<
byte
[]>
initializationData
)
{
int
sampleRate
,
List
<
byte
[]>
initializationData
)
{
return
new
MediaFormat
(
mimeType
,
maxInputSize
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
channelCount
,
return
new
MediaFormat
(
mimeType
,
maxInputSize
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
channelCount
,
sampleRate
,
initializationData
);
sampleRate
,
NO_VALUE
,
initializationData
);
}
public
static
MediaFormat
createAudioFormat
(
String
mimeType
,
int
maxInputSize
,
int
channelCount
,
int
sampleRate
,
int
bitrate
,
List
<
byte
[]>
initializationData
)
{
return
new
MediaFormat
(
mimeType
,
maxInputSize
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
channelCount
,
sampleRate
,
bitrate
,
initializationData
);
}
}
@TargetApi
(
16
)
@TargetApi
(
16
)
...
@@ -87,6 +95,7 @@ public class MediaFormat {
...
@@ -87,6 +95,7 @@ public class MediaFormat {
height
=
getOptionalIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_HEIGHT
);
height
=
getOptionalIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_HEIGHT
);
channelCount
=
getOptionalIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_CHANNEL_COUNT
);
channelCount
=
getOptionalIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_CHANNEL_COUNT
);
sampleRate
=
getOptionalIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_SAMPLE_RATE
);
sampleRate
=
getOptionalIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_SAMPLE_RATE
);
bitrate
=
getOptionalIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_BIT_RATE
);
pixelWidthHeightRatio
=
getOptionalFloatV16
(
format
,
KEY_PIXEL_WIDTH_HEIGHT_RATIO
);
pixelWidthHeightRatio
=
getOptionalFloatV16
(
format
,
KEY_PIXEL_WIDTH_HEIGHT_RATIO
);
initializationData
=
new
ArrayList
<
byte
[]>();
initializationData
=
new
ArrayList
<
byte
[]>();
for
(
int
i
=
0
;
format
.
containsKey
(
"csd-"
+
i
);
i
++)
{
for
(
int
i
=
0
;
format
.
containsKey
(
"csd-"
+
i
);
i
++)
{
...
@@ -101,7 +110,7 @@ public class MediaFormat {
...
@@ -101,7 +110,7 @@ public class MediaFormat {
}
}
private
MediaFormat
(
String
mimeType
,
int
maxInputSize
,
int
width
,
int
height
,
private
MediaFormat
(
String
mimeType
,
int
maxInputSize
,
int
width
,
int
height
,
float
pixelWidthHeightRatio
,
int
channelCount
,
int
sampleRate
,
float
pixelWidthHeightRatio
,
int
channelCount
,
int
sampleRate
,
int
bitrate
,
List
<
byte
[]>
initializationData
)
{
List
<
byte
[]>
initializationData
)
{
this
.
mimeType
=
mimeType
;
this
.
mimeType
=
mimeType
;
this
.
maxInputSize
=
maxInputSize
;
this
.
maxInputSize
=
maxInputSize
;
...
@@ -110,6 +119,7 @@ public class MediaFormat {
...
@@ -110,6 +119,7 @@ public class MediaFormat {
this
.
pixelWidthHeightRatio
=
pixelWidthHeightRatio
;
this
.
pixelWidthHeightRatio
=
pixelWidthHeightRatio
;
this
.
channelCount
=
channelCount
;
this
.
channelCount
=
channelCount
;
this
.
sampleRate
=
sampleRate
;
this
.
sampleRate
=
sampleRate
;
this
.
bitrate
=
bitrate
;
this
.
initializationData
=
initializationData
==
null
?
Collections
.<
byte
[]>
emptyList
()
this
.
initializationData
=
initializationData
==
null
?
Collections
.<
byte
[]>
emptyList
()
:
initializationData
;
:
initializationData
;
maxWidth
=
NO_VALUE
;
maxWidth
=
NO_VALUE
;
...
@@ -145,6 +155,7 @@ public class MediaFormat {
...
@@ -145,6 +155,7 @@ public class MediaFormat {
result
=
31
*
result
+
maxHeight
;
result
=
31
*
result
+
maxHeight
;
result
=
31
*
result
+
channelCount
;
result
=
31
*
result
+
channelCount
;
result
=
31
*
result
+
sampleRate
;
result
=
31
*
result
+
sampleRate
;
result
=
31
*
result
+
bitrate
;
for
(
int
i
=
0
;
i
<
initializationData
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
initializationData
.
size
();
i
++)
{
result
=
31
*
result
+
Arrays
.
hashCode
(
initializationData
.
get
(
i
));
result
=
31
*
result
+
Arrays
.
hashCode
(
initializationData
.
get
(
i
));
}
}
...
@@ -180,6 +191,7 @@ public class MediaFormat {
...
@@ -180,6 +191,7 @@ public class MediaFormat {
||
(!
ignoreMaxDimensions
&&
(
maxWidth
!=
other
.
maxWidth
||
maxHeight
!=
other
.
maxHeight
))
||
(!
ignoreMaxDimensions
&&
(
maxWidth
!=
other
.
maxWidth
||
maxHeight
!=
other
.
maxHeight
))
||
channelCount
!=
other
.
channelCount
||
sampleRate
!=
other
.
sampleRate
||
channelCount
!=
other
.
channelCount
||
sampleRate
!=
other
.
sampleRate
||
!
Util
.
areEqual
(
mimeType
,
other
.
mimeType
)
||
!
Util
.
areEqual
(
mimeType
,
other
.
mimeType
)
||
bitrate
!=
other
.
bitrate
||
initializationData
.
size
()
!=
other
.
initializationData
.
size
())
{
||
initializationData
.
size
()
!=
other
.
initializationData
.
size
())
{
return
false
;
return
false
;
}
}
...
@@ -194,8 +206,8 @@ public class MediaFormat {
...
@@ -194,8 +206,8 @@ public class MediaFormat {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"MediaFormat("
+
mimeType
+
", "
+
maxInputSize
+
", "
+
width
+
", "
+
height
+
", "
return
"MediaFormat("
+
mimeType
+
", "
+
maxInputSize
+
", "
+
width
+
", "
+
height
+
", "
+
pixelWidthHeightRatio
+
", "
+
channelCount
+
", "
+
sampleRate
+
", "
+
maxWidth
+
", "
+
pixelWidthHeightRatio
+
", "
+
channelCount
+
", "
+
sampleRate
+
", "
+
bitrate
+
", "
+
maxHeight
+
")"
;
+
max
Width
+
", "
+
max
Height
+
")"
;
}
}
/**
/**
...
@@ -211,6 +223,7 @@ public class MediaFormat {
...
@@ -211,6 +223,7 @@ public class MediaFormat {
maybeSetIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_HEIGHT
,
height
);
maybeSetIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_HEIGHT
,
height
);
maybeSetIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_CHANNEL_COUNT
,
channelCount
);
maybeSetIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_CHANNEL_COUNT
,
channelCount
);
maybeSetIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_SAMPLE_RATE
,
sampleRate
);
maybeSetIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_SAMPLE_RATE
,
sampleRate
);
maybeSetIntegerV16
(
format
,
android
.
media
.
MediaFormat
.
KEY_BIT_RATE
,
bitrate
);
maybeSetFloatV16
(
format
,
KEY_PIXEL_WIDTH_HEIGHT_RATIO
,
pixelWidthHeightRatio
);
maybeSetFloatV16
(
format
,
KEY_PIXEL_WIDTH_HEIGHT_RATIO
,
pixelWidthHeightRatio
);
for
(
int
i
=
0
;
i
<
initializationData
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
initializationData
.
size
();
i
++)
{
format
.
setByteBuffer
(
"csd-"
+
i
,
ByteBuffer
.
wrap
(
initializationData
.
get
(
i
)));
format
.
setByteBuffer
(
"csd-"
+
i
,
ByteBuffer
.
wrap
(
initializationData
.
get
(
i
)));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment