# Path: chirp/common/mp3_header.py
# STEREO = 0
# JOINT_STEREO = 1
# DUAL_MONO = 2
# MONO = 3
# _CHANNELS_TO_STR = {
#     STEREO: 'stereo',
#     JOINT_STEREO: 'joint_stereo',
#     DUAL_MONO: 'dual_mono',
#     MONO: 'mono',
#     None: None,
# }
# _PROTECTED_TABLE = (True, False)
# _BIT_RATE_KBPS_TABLE = (0, 32, 40, 48, 56, 64, 80, 96,
#                         112, 128, 160, 192, 224, 256, 320)
# _SAMPLING_RATE_HZ_TABLE = (44100, 48000, 32000)
# _PADDING_TABLE = (False, True)
# _SAMPLES_PER_FRAME = 1152
# def _match_eq(x, y):
#     def __init__(self, sampling_rate_hz=None, bit_rate_kbps=None,
#                  channels=None, protected=None, padding=None):
#     def is_complete(self):
#     def match(self, hdr):
#     def __str__(self):
# def parse(data, offset=0):
# def find(data, expected_hdr=None):
# def from_mutagen(mutagen_mp3):
# class MP3Header(object):


import unittest
import sys
import mutagen.mp3
from chirp.common import mp3_header
                '123\xff123\xff' + raw_hdr,
                raw_hdr + '\xff',
                ):
                found_hdr, offset = mp3_header.find(test_data)
                self.assertEqual(test_data.find(raw_hdr), offset)
                self.assertTrue(found_hdr is not None)
                self.assertTrue(hdr.match(found_hdr))

    def test_from_mutagen(self):
        mp3 = mutagen.mp3.MP3()

        class MockInfo(mutagen.mp3.MPEGInfo):
            def __init__(self):
                pass

        mp3.info = MockInfo()
        mp3.info.sample_rate = 12345
        mp3.info.bitrate = 123456
        mp3.info.mode = mp3_header.STEREO

        hdr = mp3_header.from_mutagen(mp3)
        self.assertEqual(12345, hdr.sampling_rate_hz)
        self.assertEqual(123.456, hdr.bit_rate_kbps)
        self.assertEqual(mp3_header.STEREO, hdr.channels)
        self.assertEqual("stereo", hdr.channels_str)

        self.assertEqual(None, hdr.protected)
        self.assertEqual(None, hdr.padding)



# Path: chirp/common/mp3_header.py
# STEREO = 0
# JOINT_STEREO = 1
# DUAL_MONO = 2
# MONO = 3
# _CHANNELS_TO_STR = {
#     STEREO: 'stereo',
#     JOINT_STEREO: 'joint_stereo',
#     DUAL_MONO: 'dual_mono',
#     MONO: 'mono',
#     None: None,
# }
# _PROTECTED_TABLE = (True, False)
# _BIT_RATE_KBPS_TABLE = (0, 32, 40, 48, 56, 64, 80, 96,
#                         112, 128, 160, 192, 224, 256, 320)
# _SAMPLING_RATE_HZ_TABLE = (44100, 48000, 32000)
# _PADDING_TABLE = (False, True)
# _SAMPLES_PER_FRAME = 1152
# def _match_eq(x, y):
#     def __init__(self, sampling_rate_hz=None, bit_rate_kbps=None,
#                  channels=None, protected=None, padding=None):
#     def is_complete(self):
#     def match(self, hdr):
#     def __str__(self):
# def parse(data, offset=0):
# def find(data, expected_hdr=None):
# def from_mutagen(mutagen_mp3):
# class MP3Header(object):


# Path: chirp/common/mp3_header_test.py
import unittest
import sys
import mutagen.mp3
from chirp.common import mp3_header

                '123\xff123\xff' + raw_hdr,
                raw_hdr + '\xff',
                ):
                found_hdr, offset = mp3_header.find(test_data)
                self.assertEqual(test_data.find(raw_hdr), offset)
                self.assertTrue(found_hdr is not None)
                self.assertTrue(hdr.match(found_hdr))

    def test_from_mutagen(self):
        mp3 = mutagen.mp3.MP3()

        class MockInfo(mutagen.mp3.MPEGInfo):
            def __init__(self):
                pass

        mp3.info = MockInfo()
        mp3.info.sample_rate = 12345
        mp3.info.bitrate = 123456
        mp3.info.mode = mp3_header.STEREO

        hdr = mp3_header.from_mutagen(mp3)
        self.assertEqual(12345, hdr.sampling_rate_hz)
        self.assertEqual(123.456, hdr.bit_rate_kbps)
        self.assertEqual(mp3_header.STEREO, hdr.channels)
        self.assertEqual("stereo", hdr.channels_str)

        self.assertEqual(None, hdr.protected)
        self.assertEqual(None, hdr.padding)



if __name__ == '__main__':