Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

SMIL::MediaClippingTime Class Reference

#include <smiltime.h>

Inheritance diagram for SMIL::MediaClippingTime:

Inheritance graph
[legend]
Collaboration diagram for SMIL::MediaClippingTime:

Collaboration graph
[legend]
List of all members.

Public Types

enum  SubframeType { SMIL_SUBFRAME_NONE, SMIL_SUBFRAME_0, SMIL_SUBFRAME_1 }

Public Member Functions

 MediaClippingTime ()
 MediaClippingTime (float framerate)
 MediaClippingTime (string time, float framerate)
virtual ~MediaClippingTime ()
void setFramerate (float framerate)
virtual void parseValue (string time)
void parseSmpteValue (string time)
virtual string toString (TimeFormat format=TIME_FORMAT_SMPTE)
virtual string serialise ()
string parseValueToString (string time, TimeFormat format)
string parseFramesToString (int frames, TimeFormat format)
int getFrames ()

Private Attributes

float m_framerate
bool m_isSmpteValue
SubframeType m_subframe

Member Enumeration Documentation

enum SMIL::MediaClippingTime::SubframeType
 

Enumeration values:
SMIL_SUBFRAME_NONE 
SMIL_SUBFRAME_0 
SMIL_SUBFRAME_1 

Definition at line 117 of file smiltime.h.

00117                  {
00118         SMIL_SUBFRAME_NONE,
00119         SMIL_SUBFRAME_0,
00120         SMIL_SUBFRAME_1
00121     } SubframeType;


Constructor & Destructor Documentation

SMIL::MediaClippingTime::MediaClippingTime  ) 
 

Definition at line 362 of file smiltime.cc.

00362                                       :
00363     Time( 0L ),
00364     m_framerate( 0.0 ), 
00365     m_isSmpteValue( false ), 
00366     m_subframe( SMIL_SUBFRAME_NONE )
00367 {
00368 }

SMIL::MediaClippingTime::MediaClippingTime float  framerate  ) 
 

Definition at line 370 of file smiltime.cc.

00370                                                       :
00371     Time( 0L ),
00372     m_framerate( framerate ),
00373     m_isSmpteValue( false ), 
00374     m_subframe( SMIL_SUBFRAME_NONE )
00375 {
00376 }

SMIL::MediaClippingTime::MediaClippingTime string  time,
float  framerate
 

Definition at line 378 of file smiltime.cc.

References parseValue().

00378                                                                    :
00379     Time( 0L ),
00380     m_framerate( framerate ),
00381     m_isSmpteValue( false ), 
00382     m_subframe( SMIL_SUBFRAME_NONE )
00383 {
00384     parseValue( time );
00385 }

virtual SMIL::MediaClippingTime::~MediaClippingTime  )  [inline, virtual]
 

Definition at line 126 of file smiltime.h.

00127     {}


Member Function Documentation

int SMIL::MediaClippingTime::getFrames  ) 
 

Definition at line 642 of file smiltime.cc.

References SMIL::Time::getResolvedOffset(), and m_framerate.

Referenced by toString().

00643 {
00644     return ( int )( m_framerate * getResolvedOffset() / 1000.0 + 0.5 );
00645 }

string SMIL::MediaClippingTime::parseFramesToString int  frames,
TimeFormat  format
 

Definition at line 613 of file smiltime.cc.

References SMIL::framesToSmpte(), SMIL::Time::indefinite, m_framerate, SMIL::Time::offset, SMIL::Time::resolved, SMIL::Time::TIME_FORMAT_FRAMES, SMIL::Time::TIME_FORMAT_NONE, SMIL::Time::TIME_FORMAT_SMPTE, SMIL::Time::timeValue, and toString().

Referenced by convertFramesToSmilTime(), and SrtContext::printEntry().

00614 {
00615     if ( m_framerate == 0 )
00616         return "";
00617     offset = 0;
00618     timeValue = ( long )( 1000.0 * frames / m_framerate + 0.5 );
00619     resolved = true;
00620     indefinite = false;
00621     
00622     switch ( format )
00623     {
00624         case TIME_FORMAT_NONE:
00625             return "";
00626         
00627         case TIME_FORMAT_FRAMES:
00628         {
00629             std::ostringstream str;
00630             str << frames;
00631             return str.str();
00632         }
00633         
00634         case TIME_FORMAT_SMPTE:
00635             return framesToSmpte( frames, ( int )m_framerate );
00636 
00637         default:
00638             return toString( format );
00639     }
00640 }

void SMIL::MediaClippingTime::parseSmpteValue string  time  ) 
 

Definition at line 413 of file smiltime.cc.

References SMIL::Time::indefinite, m_framerate, m_isSmpteValue, m_subframe, SMIL::Time::resolved, SMIL_SUBFRAME_0, SMIL_SUBFRAME_1, SMIL_SUBFRAME_NONE, and SMIL::Time::timeValue.

Referenced by parseValue(), and parseValueToString().

00414 {
00415     string hours;
00416     string minutes;
00417     string seconds;
00418     string frames;
00419     string::size_type pos;
00420 
00421     if ( m_framerate == 0 )
00422         return;
00423     
00424     m_isSmpteValue = true;
00425 
00426     if ( ( pos = time.find( ':' ) ) != string::npos || ( pos = time.find( ';' ) ) != string::npos )
00427     {
00428         //cerr << "smil: parsing HH SMPTE value " << time << endl;
00429         hours = time.substr( 0, pos );
00430         time = time.substr( pos + 1 );
00431 
00432         if ( ( pos = time.find( ':' ) ) != string::npos || ( pos = time.find( ';' ) ) != string::npos )
00433         {
00434             //cerr << "smil: parsing MM SMPTE value " << time << endl;
00435             minutes = time.substr( 0, pos );
00436             time = time.substr( pos + 1 );
00437 
00438             if ( ( pos = time.find( ':' ) ) != string::npos || ( pos = time.find( ';' ) ) != string::npos )
00439             {
00440                 //cerr << "smil: parsing SS SMPTE value " << time << endl;
00441                 seconds = time.substr( 0, pos );
00442                 time = time.substr( pos + 1 );
00443 
00444                 if ( ( pos = time.find( '.' ) ) != string::npos )
00445                 {
00446                     //cerr << "smil: parsing FF SMPTE value " << time << endl;
00447                     frames = time.substr( 0, pos );
00448                     switch ( time.at( pos + 1 ) )
00449                     {
00450                     case '0' :
00451                         m_subframe = SMIL_SUBFRAME_0;
00452                         break;
00453                     case '1' :
00454                         m_subframe = SMIL_SUBFRAME_1;
00455                         break;
00456                     default:
00457                         m_subframe = SMIL_SUBFRAME_NONE;
00458                         break;
00459                     }
00460                 }
00461                 else
00462                 {
00463                     frames = time;
00464                 }
00465             }
00466             else
00467             {
00468                 // minutes, seconds, and frames only
00469                 frames = time;
00470                 seconds = minutes;
00471                 minutes = hours;
00472                 hours = "";
00473             }
00474         }
00475         else
00476         {
00477             // frames and seconds only
00478             frames = time;
00479             seconds = hours;
00480             hours = "";
00481         }
00482     }
00483     else
00484     {
00485         // frames only
00486         frames = time;
00487     }
00488     
00489     //cerr << "hh = " << hours << ", mm = " << minutes << ", ss = " << seconds << ", ff = " << frames << endl;
00490     timeValue = ( atol( hours.c_str() ) * 3600 + atol( minutes.c_str() ) * 60 +
00491                   atol( seconds.c_str() ) ) * 1000 + 
00492                   ( long )( atof( frames.c_str() ) / m_framerate * 1000 + 0.5 );
00493 
00494     resolved = true;
00495     indefinite = false;
00496 }

void SMIL::MediaClippingTime::parseValue string  time  )  [virtual]
 

Definition at line 394 of file smiltime.cc.

References StringUtils::begins(), parseSmpteValue(), SMIL::Time::parseTimeValue(), and StringUtils::stripWhite().

Referenced by convertSmilTimeToFrames(), MediaClippingTime(), and parseValueToString().

00395 {
00396     time = StringUtils::stripWhite( time );
00397     //cerr << "smil: parsing media clipping time " << time << endl;
00398     if ( StringUtils::begins( time, "smpte=" ) ||
00399             StringUtils::begins( time, "smpte-30-drop=" ) ||
00400             StringUtils::begins( time, "smpte-25=" ) )
00401     {
00402         parseSmpteValue( time.substr( time.find( '=' ) + 1 ) );
00403     }
00404     else if ( time.find( '=' ) != string::npos )    // discard npt=
00405     {
00406         parseTimeValue( time.substr( time.find( '=' ) + 1 ) );
00407     } else
00408     {
00409         parseTimeValue( time );
00410     }
00411 }

string SMIL::MediaClippingTime::parseValueToString string  time,
TimeFormat  format
 

Definition at line 601 of file smiltime.cc.

References SMIL::Time::offset, parseSmpteValue(), parseValue(), SMIL::Time::TIME_FORMAT_FRAMES, SMIL::Time::TIME_FORMAT_NONE, SMIL::Time::TIME_FORMAT_SMPTE, SMIL::Time::timeValue, and toString().

00602 {
00603     offset = 0;
00604     timeValue = 0;
00605     if ( format == TIME_FORMAT_NONE || format == TIME_FORMAT_FRAMES || format == TIME_FORMAT_SMPTE )
00606         parseSmpteValue( time );
00607     else
00608         parseValue( time );
00609     return toString( format );
00610 }

string SMIL::MediaClippingTime::serialise  )  [virtual]
 

Reimplemented from SMIL::Time.

Definition at line 542 of file smiltime.cc.

References m_framerate, m_isSmpteValue, SMIL::Time::toString(), and toString().

00543 {
00544     std::string s;
00545     if ( m_isSmpteValue )
00546     {
00547         if ( m_framerate == 25.0 )
00548             s = "smpte-25=";
00549         else
00550             s = "smpte=";
00551         
00552         return s + toString();
00553     }
00554     return Time::toString();
00555 }

void SMIL::MediaClippingTime::setFramerate float  framerate  ) 
 

Definition at line 388 of file smiltime.cc.

References m_framerate.

Referenced by convertFramesToSmilTime(), convertSmilTimeToFrames(), and SrtContext::printEntry().

00389 {
00390     m_framerate = framerate;
00391 }

string SMIL::MediaClippingTime::toString TimeFormat  format = TIME_FORMAT_SMPTE  )  [virtual]
 

Reimplemented from SMIL::Time.

Definition at line 498 of file smiltime.cc.

References getFrames(), SMIL::Time::getResolvedOffset(), SMIL::Time::indefinite, m_framerate, m_subframe, SMIL::Time::resolved, SMIL_SUBFRAME_0, SMIL_SUBFRAME_1, SMIL::Time::TIME_FORMAT_FRAMES, SMIL::Time::TIME_FORMAT_SMPTE, and SMIL::Time::toString().

Referenced by convertSmilTimeToFrames(), parseFramesToString(), parseValueToString(), and serialise().

00499 {
00500     if ( format == TIME_FORMAT_SMPTE )
00501     {
00502         if ( indefinite )
00503             return "indefinite";
00504         else if ( !resolved )
00505             return "unresolved";
00506         else
00507         {
00508             long ms = getResolvedOffset();
00509             int hh = ( ms / 3600000 );
00510             ms -= hh * 3600000;
00511             int mm = ( ms / 60000 );
00512             ms -= mm * 60000;
00513             int ss = ms / 1000;
00514             ms -= ss * 1000;
00515 
00516             ostringstream str;
00517             str << hh << ":" << std::setfill( '0' ) << std::setw( 2 ) << 
00518                 mm << ":" << std::setfill( '0' ) << std::setw( 2 ) << ss << 
00519                 ( m_framerate == 25.0 ? ":" : ";" ) << 
00520                 std::setfill( '0' ) << std::setw( 2 ) << 
00521                 floor( m_framerate * ms / 1000.0 + 0.5 );
00522             if ( m_subframe == SMIL_SUBFRAME_0 )
00523                 str << ".0";
00524             else if ( m_subframe == SMIL_SUBFRAME_1 )
00525                 str << ".1";
00526 
00527             return str.str();
00528         }
00529     }
00530     else if ( format == TIME_FORMAT_FRAMES )
00531     {
00532         std::ostringstream str;
00533         str << getFrames();
00534         return str.str();
00535     }
00536     else
00537     {
00538         return Time::toString( format );
00539     }
00540 }


Member Data Documentation

float SMIL::MediaClippingTime::m_framerate [private]
 

Definition at line 140 of file smiltime.h.

Referenced by getFrames(), parseFramesToString(), parseSmpteValue(), serialise(), setFramerate(), and toString().

bool SMIL::MediaClippingTime::m_isSmpteValue [private]
 

Definition at line 141 of file smiltime.h.

Referenced by parseSmpteValue(), and serialise().

SubframeType SMIL::MediaClippingTime::m_subframe [private]
 

Definition at line 142 of file smiltime.h.

Referenced by parseSmpteValue(), and toString().


The documentation for this class was generated from the following files:
Generated on Sun Mar 11 22:13:30 2007 for Kino by  doxygen 1.4.2