summaryrefslogtreecommitdiffstats
path: root/macosx/TargetSizeField.mm
blob: e113a4bf15bcf4b393901d27be6a800f8be40e88 (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
/* $Id: TargetSizeField.mm,v 1.4 2004/01/28 14:41:31 titer Exp $

   This file is part of the HandBrake source code.
   Homepage: <http://handbrake.m0k.org/>.
   It may be used under the terms of the GNU General Public License. */

#include "TargetSizeField.h"

@implementation HBTargetSizeField

- (void) textDidBeginEditing: (NSNotification *) notification
{
    [self UpdateBitrate];
    [super textDidBeginEditing: notification];
}

- (void) textDidEndEditing: (NSNotification *) notification
{
    [self UpdateBitrate];
    [super textDidEndEditing: notification];
}

- (void) textDidChange: (NSNotification *) notification
{
    [self UpdateBitrate];
    [super textDidChange: notification];
}

- (void) SetHBTitle: (HBTitle*) title
{
    fTitle = title;
}

- (void) UpdateBitrate
{
    int size   = [self intValue];
    int format = [fRipFormatPopUp indexOfSelectedItem];
    int muxer  = ( format == 0 ) ? HB_MUX_MP4 : ( ( format == 1 ) ?
            HB_MUX_OGM : HB_MUX_AVI );
    int audioCount = ( [fRipLang2PopUp selectedItem] ==
            [fRipLang2PopUp lastItem] ) ? 1 : 2;
    int audioBitrate = [[fRipAudBitPopUp titleOfSelectedItem] intValue];

    [fRipCustomField setIntValue: HBGetBitrateForSize( fTitle, size,
            muxer, audioCount, audioBitrate )];
}

@end