Rewrote header, updated source.
+alphabranch git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32786 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
cb3f273dd2
commit
224f4fcd63
@ -1,119 +1,108 @@
|
||||
/*****************************************************************
|
||||
|
||||
File: TimeCode.h
|
||||
|
||||
Description: Time code handling functions and class
|
||||
|
||||
Copyright 1998-, Be Incorporated. All Rights Reserved.
|
||||
|
||||
*****************************************************************/
|
||||
|
||||
#if !defined(_TIME_CODE_H)
|
||||
/*
|
||||
* Copyright 2009, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _TIME_CODE_H
|
||||
#define _TIME_CODE_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
/* Time code is always in the form HH:MM:SS:FF, it's the definition of FF that varies */
|
||||
// Time code is always in the form HH:MM:SS:FF, it's the definition of "FF"
|
||||
// that varies
|
||||
enum timecode_type {
|
||||
B_TIMECODE_DEFAULT,
|
||||
B_TIMECODE_100,
|
||||
B_TIMECODE_75, /* CD */
|
||||
B_TIMECODE_30, /* MIDI */
|
||||
B_TIMECODE_30_DROP_2, /* NTSC */
|
||||
B_TIMECODE_30_DROP_4, /* Brazil */
|
||||
B_TIMECODE_25, /* PAL */
|
||||
B_TIMECODE_24, /* Film */
|
||||
B_TIMECODE_18 /* Super8 */
|
||||
B_TIMECODE_75, // CD
|
||||
B_TIMECODE_30, // MIDI
|
||||
B_TIMECODE_30_DROP_2, // NTSC
|
||||
B_TIMECODE_30_DROP_4, // Brazil
|
||||
B_TIMECODE_25, // PAL
|
||||
B_TIMECODE_24, // Film
|
||||
B_TIMECODE_18 // Super8
|
||||
};
|
||||
|
||||
|
||||
struct timecode_info {
|
||||
timecode_type type;
|
||||
int drop_frames;
|
||||
int every_nth;
|
||||
int except_nth;
|
||||
int fps_div;
|
||||
char name[32]; /* for popup menu etc */
|
||||
char format[32]; /* for sprintf(fmt, h, m, s, f) */
|
||||
char _reserved_[64];
|
||||
timecode_type type;
|
||||
int drop_frames;
|
||||
int every_nth;
|
||||
int except_nth;
|
||||
int fps_div;
|
||||
char name[32]; // For popup menus and such
|
||||
char format[32]; // For sprintf(fmt, h, m, s, f)
|
||||
|
||||
char _reserved_[64];
|
||||
};
|
||||
status_t us_to_timecode(bigtime_t micros, int * hours, int * minutes, int * seconds, int * frames, const timecode_info * code = NULL);
|
||||
status_t timecode_to_us(int hours, int minutes, int seconds, int frames, bigtime_t * micros, const timecode_info * code = NULL);
|
||||
status_t frames_to_timecode(int32 l_frames, int * hours, int * minutes, int * seconds, int * frames, const timecode_info * code = NULL);
|
||||
status_t timecode_to_frames(int hours, int minutes, int seconds, int frames, int32 * l_frames, const timecode_info * code = NULL);
|
||||
status_t get_timecode_description(timecode_type type, timecode_info * out_timecode);
|
||||
|
||||
|
||||
status_t us_to_timecode(bigtime_t micros, int* hours, int* minutes,
|
||||
int* seconds, int* frames, const timecode_info* code = NULL);
|
||||
|
||||
status_t timecode_to_us(int hours, int minutes, int seconds, int frames,
|
||||
bigtime_t* micros, const timecode_info* code = NULL);
|
||||
|
||||
status_t frames_to_timecode(int32 l_frames, int* hours, int* minutes,
|
||||
int* seconds, int* frames, const timecode_info* code = NULL);
|
||||
|
||||
status_t timecode_to_frames(int hours, int minutes, int seconds, int frames,
|
||||
int32* lFrames, const timecode_info* code = NULL);
|
||||
|
||||
status_t get_timecode_description(timecode_type type,
|
||||
timecode_info* _timecode);
|
||||
|
||||
status_t count_timecodes();
|
||||
/* we may want a set_default_timecode, too -- but that's bad from a thread standpoint */
|
||||
|
||||
|
||||
class BTimeCode {
|
||||
public:
|
||||
BTimeCode();
|
||||
BTimeCode(
|
||||
bigtime_t us,
|
||||
timecode_type type = B_TIMECODE_DEFAULT);
|
||||
BTimeCode(
|
||||
const BTimeCode & clone);
|
||||
BTimeCode(
|
||||
int hours,
|
||||
int minutes,
|
||||
int seconds,
|
||||
int frames,
|
||||
timecode_type type = B_TIMECODE_DEFAULT);
|
||||
~BTimeCode();
|
||||
BTimeCode();
|
||||
BTimeCode(bigtime_t microSeconds,
|
||||
timecode_type type = B_TIMECODE_DEFAULT);
|
||||
BTimeCode(const BTimeCode& other);
|
||||
BTimeCode(int hours, int minutes, int seconds,
|
||||
int frames,
|
||||
timecode_type type = B_TIMECODE_DEFAULT);
|
||||
~BTimeCode();
|
||||
|
||||
void SetData(
|
||||
int hours,
|
||||
int minutes,
|
||||
int seconds,
|
||||
int frames);
|
||||
status_t SetType(
|
||||
timecode_type type);
|
||||
void SetMicroseconds(
|
||||
bigtime_t us);
|
||||
void SetLinearFrames(
|
||||
int32 linear_frames);
|
||||
void SetData(int hours, int minutes, int seconds,
|
||||
int frames);
|
||||
status_t SetType(timecode_type type);
|
||||
void SetMicroseconds(bigtime_t microSeconds);
|
||||
void SetLinearFrames(int32 linearFrames);
|
||||
|
||||
BTimeCode & operator=(
|
||||
const BTimeCode & clone);
|
||||
bool operator==(
|
||||
const BTimeCode & other) const;
|
||||
bool operator<(
|
||||
const BTimeCode & other) const;
|
||||
BTimeCode& operator=(const BTimeCode& other);
|
||||
bool operator==(const BTimeCode& other) const;
|
||||
bool operator<(const BTimeCode& other) const;
|
||||
|
||||
BTimeCode & operator+=(
|
||||
const BTimeCode & other);
|
||||
BTimeCode & operator-=(
|
||||
const BTimeCode & other);
|
||||
BTimeCode& operator+=(const BTimeCode& other);
|
||||
BTimeCode& operator-=(const BTimeCode& other);
|
||||
|
||||
BTimeCode operator+(
|
||||
const BTimeCode & other) const;
|
||||
BTimeCode operator-(
|
||||
const BTimeCode & other) const;
|
||||
BTimeCode operator+(const BTimeCode& other) const;
|
||||
BTimeCode operator-(const BTimeCode& other) const;
|
||||
|
||||
int Hours() const;
|
||||
int Minutes() const;
|
||||
int Seconds() const;
|
||||
int Frames() const;
|
||||
timecode_type Type() const;
|
||||
void GetData(
|
||||
int * out_hours,
|
||||
int * out_minutes,
|
||||
int * out_seconds,
|
||||
int * out_frames,
|
||||
timecode_type * out_type = NULL) const;
|
||||
int Hours() const;
|
||||
int Minutes() const;
|
||||
int Seconds() const;
|
||||
int Frames() const;
|
||||
timecode_type Type() const;
|
||||
void GetData(int* _hours, int* _minutes,
|
||||
int* _seconds, int* _frames,
|
||||
timecode_type* _type = NULL) const;
|
||||
|
||||
bigtime_t Microseconds() const;
|
||||
int32 LinearFrames() const;
|
||||
void GetString(
|
||||
char * str) const; /* at least 24 bytes */
|
||||
bigtime_t Microseconds() const;
|
||||
int32 LinearFrames() const;
|
||||
|
||||
// Make sure the passed buffer is at least 24 bytes large.
|
||||
void GetString(char* string) const;
|
||||
|
||||
private:
|
||||
int m_hours;
|
||||
int m_minutes;
|
||||
int m_seconds;
|
||||
int m_frames;
|
||||
timecode_info m_info;
|
||||
int fHours;
|
||||
int fMinutes;
|
||||
int fSeconds;
|
||||
int fFrames;
|
||||
timecode_info fInfo;
|
||||
};
|
||||
|
||||
|
||||
#endif /* _TIME_CODE_H */
|
||||
#endif // _TIME_CODE_H
|
||||
|
@ -298,10 +298,10 @@ BTimeCode::SetData(int hours,
|
||||
int frames)
|
||||
{
|
||||
CALLED();
|
||||
m_hours = hours;
|
||||
m_minutes = minutes;
|
||||
m_seconds = seconds;
|
||||
m_frames = frames;
|
||||
fHours = hours;
|
||||
fMinutes = minutes;
|
||||
fSeconds = seconds;
|
||||
fFrames = frames;
|
||||
}
|
||||
|
||||
|
||||
@ -310,7 +310,7 @@ BTimeCode::SetType(timecode_type type)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
return get_timecode_description(type, &m_info);
|
||||
return get_timecode_description(type, &fInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -319,7 +319,7 @@ BTimeCode::SetMicroseconds(bigtime_t us)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
us_to_timecode(us, &m_hours, &m_minutes, &m_seconds, &m_frames, &m_info);
|
||||
us_to_timecode(us, &fHours, &fMinutes, &fSeconds, &fFrames, &fInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -328,7 +328,7 @@ BTimeCode::SetLinearFrames(int32 linear_frames)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
frames_to_timecode(linear_frames, &m_hours, &m_minutes, &m_seconds, &m_frames, &m_info);
|
||||
frames_to_timecode(linear_frames, &fHours, &fMinutes, &fSeconds, &fFrames, &fInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -336,10 +336,10 @@ BTimeCode &
|
||||
BTimeCode::operator=(const BTimeCode &clone)
|
||||
{
|
||||
CALLED();
|
||||
m_hours = clone.Hours();
|
||||
m_minutes = clone.Minutes();
|
||||
m_seconds = clone.Seconds();
|
||||
m_frames = clone.Frames();
|
||||
fHours = clone.Hours();
|
||||
fMinutes = clone.Minutes();
|
||||
fSeconds = clone.Seconds();
|
||||
fFrames = clone.Frames();
|
||||
SetType(clone.Type());
|
||||
|
||||
return *this;
|
||||
@ -411,7 +411,7 @@ BTimeCode::Hours() const
|
||||
{
|
||||
CALLED();
|
||||
|
||||
return m_hours;
|
||||
return fHours;
|
||||
}
|
||||
|
||||
|
||||
@ -420,7 +420,7 @@ BTimeCode::Minutes() const
|
||||
{
|
||||
CALLED();
|
||||
|
||||
return m_minutes;
|
||||
return fMinutes;
|
||||
}
|
||||
|
||||
|
||||
@ -429,7 +429,7 @@ BTimeCode::Seconds() const
|
||||
{
|
||||
CALLED();
|
||||
|
||||
return m_seconds;
|
||||
return fSeconds;
|
||||
}
|
||||
|
||||
|
||||
@ -438,7 +438,7 @@ BTimeCode::Frames() const
|
||||
{
|
||||
CALLED();
|
||||
|
||||
return m_frames;
|
||||
return fFrames;
|
||||
}
|
||||
|
||||
|
||||
@ -447,7 +447,7 @@ BTimeCode::Type() const
|
||||
{
|
||||
CALLED();
|
||||
|
||||
return m_info.type;
|
||||
return fInfo.type;
|
||||
}
|
||||
|
||||
|
||||
@ -459,11 +459,11 @@ BTimeCode::GetData(int *out_hours,
|
||||
timecode_type *out_type) const
|
||||
{
|
||||
CALLED();
|
||||
*out_hours = m_hours;
|
||||
*out_minutes = m_minutes;
|
||||
*out_seconds = m_seconds;
|
||||
*out_frames = m_frames;
|
||||
*out_type = m_info.type;
|
||||
*out_hours = fHours;
|
||||
*out_minutes = fMinutes;
|
||||
*out_seconds = fSeconds;
|
||||
*out_frames = fFrames;
|
||||
*out_type = fInfo.type;
|
||||
}
|
||||
|
||||
|
||||
@ -474,7 +474,7 @@ BTimeCode::Microseconds() const
|
||||
|
||||
CALLED();
|
||||
|
||||
if (timecode_to_us(m_hours,m_minutes,m_seconds,m_frames, &us, &m_info) == B_OK) {
|
||||
if (timecode_to_us(fHours,fMinutes,fSeconds,fFrames, &us, &fInfo) == B_OK) {
|
||||
return us;
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ BTimeCode::LinearFrames() const
|
||||
|
||||
CALLED();
|
||||
|
||||
if (timecode_to_frames(m_hours,m_minutes,m_seconds,m_frames,&linear_frames,&m_info) == B_OK) {
|
||||
if (timecode_to_frames(fHours,fMinutes,fSeconds,fFrames,&linear_frames,&fInfo) == B_OK) {
|
||||
return linear_frames;
|
||||
}
|
||||
|
||||
@ -501,5 +501,5 @@ void
|
||||
BTimeCode::GetString(char *str) const
|
||||
{
|
||||
CALLED();
|
||||
sprintf(str,m_info.format, m_hours, m_minutes, m_seconds, m_frames);
|
||||
sprintf(str,fInfo.format, fHours, fMinutes, fSeconds, fFrames);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user