forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestAudioFrame.py
More file actions
52 lines (42 loc) · 1.56 KB
/
Copy pathtestAudioFrame.py
File metadata and controls
52 lines (42 loc) · 1.56 KB
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
from nose.tools import *
from pyAvTranscoder import avtranscoder as av
@raises(MemoryError)
def testInvalidAudioFrameAutoAllocated():
"""
Try to create an invalid AudioFrame automatically allocated.
"""
desc = av.AudioFrameDesc(4800, 1, "toto")
av.AudioFrame(desc)
@raises(MemoryError)
def testInvalidAudioFrameManualAllocated():
"""
Try to create an invalid AudioFrame manually allocated.
"""
sampleRate = 48000
nbChannels = 1
sampleFormat = "titi"
desc = av.AudioFrameDesc(sampleRate, nbChannels, sampleFormat)
frame = av.AudioFrame(desc, False)
assert_equals(frame.isDataAllocated(), False)
assert_equals(frame.getDataSize(), 0)
assert_equals(frame.getSampleRate(), sampleRate)
assert_equals(frame.getNbChannels(), nbChannels)
assert_equals(frame.getChannelLayoutDesc(), "mono")
assert_equals(frame.getNbSamplesPerChannel(), 1920)
assert_equals(frame.getBytesPerSample(), 0)
assert_equals(av.getSampleFormatName(frame.getSampleFormat()), "")
frame.allocateData()
def testAudioFrame():
"""
Check the size and the data buffer of a AudioFrame.
"""
sampleRate = 48000
nbChannels = 1
sampleFormat = "s32"
desc = av.AudioFrameDesc(sampleRate, nbChannels, sampleFormat)
frame = av.AudioFrame(desc)
assert_equals(frame.isDataAllocated(), True)
assert_equals(frame.isAudioFrame(), True)
assert_equals(frame.getDataSize(), frame.getNbSamplesPerChannel() * frame.getBytesPerSample() * nbChannels)
frame.freeData()
assert_equals(frame.isDataAllocated(), False)