//
//  FFmpegController.h
//  FFmpegWrapper
//
//  Created by Scott on 3/28/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface FWFileTranscoder : NSObject {
	
	// private data members
	id							 delegate;
	long						 duration;
	long						 actualDuration;
	NSString					*applicationUrl;
	NSMutableArray				*applicationSettings;
	NSTask						*task;
	int							 priority;
	NSPipe						*inputPipe;
	NSPipe						*outputPipe;
	NSFileHandle				*taskInput;
	NSFileHandle				*taskOutput;
	NSString					*outputBuffer;
	NSTimer						*monitorTimer;
	int							 linesSinceLastMonitor;
	NSString					*lastLine;	
	BOOL						 isInputStream;
	int							 restartCount;
	BOOL						 isSuspended;
	
	BOOL						 errorPixelAspectRatio;
	BOOL						 errorTimeBaseNotSupported;
	BOOL						 errorStream01;
	BOOL						 errorContainerFrameRate;
	BOOL						 errorG2M3;
	BOOL						 errorWMAPro;
	
	NSString					*inputDimensions;
	NSString					*inputFrameRate;
}


// accessor members
- (id)delegate;
- (void)setDelegate:(id)value;

// public method members
- (id)initWithFFmpegURL:(NSURL *)ffmpegURL settings:(NSMutableArray *)settings;
- (void)start;
- (void)stop;
- (void)suspend;
- (void)resume;
- (BOOL)isSuspended;
- (void)taskCompleted:(NSNotification *)notif;
- (void)processTaskOutput:(NSString *)output;
- (void)taskDataAvailable:(NSNotification *)notif;
- (void)sendData:(NSString *)dataString;
- (NSString *)actionText;
- (long)actualDuration;
- (void)setActualDuration:(long)actualDuration;
- (void)executeWithSettings:(NSMutableArray *)settings;
- (void)executeWithSettings:(NSMutableArray *)settings waitForCompletion:(BOOL)_wait;

// private method members
- (long)parseToSeconds:(NSString *)text;
- (NSMutableDictionary *)parseToDictionary:(NSString *)text;
- (void)handleDurationLine:(NSString *)line;
- (void)handleFrameLine:(NSString *)line;
- (void)handleStreamLine:(NSString *)line;
- (void)handleErrorContainerFrameRateNtscLine:(NSString*)line;
- (void)handleErrorStream01Line:(NSString *)line;
- (BOOL)fixErrors;

@end
