00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "stdafx.h"
00036
00037 #include <libCMMLParse/CMMLTagUtils.h>
00038 #include <libTemporalURI/C_TimeStamp.h>
00039
00040 #include <fstream>
00041
00042 #undef DEBUG
00043
00046 C_ClipTagList *CMMLTagUtils::getClipsFrom(C_ClipTagList *inClipTagList, LOOG_INT64 inTimeInDirectShowUnits)
00047 {
00048
00049 #ifdef DEBUG
00050 fstream locDebugFile;
00051 locDebugFile.open("G:\\Logs\\getClipsFrom.log", ios_base::out);
00052 #endif
00053
00054 C_ClipTagList *locClipTagList = new C_ClipTagList;
00055
00056 bool locAlreadyEncounteredClipInTimeRange = false;
00057
00058 for (unsigned long i = 0; i < inClipTagList->numTags(); i++) {
00059 C_ClipTag *locTag = inClipTagList->getTag(i);
00060
00061 #ifdef DEBUG
00062 locDebugFile << "Processing tag " << i << endl;
00063 #endif
00064
00065
00066 wstring locStart = locTag->start();
00067 C_TimeStamp locTimeStamp;
00068 if (!locTimeStamp.parseTimeStamp(StringHelper::toNarrowStr(locStart))) {
00069 #ifdef DEBUG
00070 locDebugFile << "Couldn't parse time stamp: " <<
00071 StringHelper::toNarrowStr(locStart) << endl;
00072 #endif
00073
00074
00075 continue;
00076 }
00077 LOOG_INT64 locStartTime = locTimeStamp.toHunNanos();
00078
00079 if (locStartTime >= inTimeInDirectShowUnits) {
00080 #ifdef DEBUG
00081 locDebugFile << "Found clip with greater start time " << locStartTime << endl;
00082 #endif
00083 if (!locAlreadyEncounteredClipInTimeRange) {
00084 {
00085
00086
00087 wstring locEnd = locTag->end();
00088 C_TimeStamp locEndTimeStamp;
00089 if (locEndTimeStamp.parseTimeStamp(StringHelper::toNarrowStr(locEnd))) {
00090
00091 LOOG_INT64 locEndTime = locEndTimeStamp.toHunNanos();
00092 if ( locEndTime != 0
00093 && locEndTime >= locStartTime
00094 && locEndTime < inTimeInDirectShowUnits) {
00095 #ifdef DEBUG
00096 locDebugFile << "Skipping add due to end time " << locEndTime << endl;
00097 #endif
00098 continue;
00099 }
00100 }
00101 }
00102
00103
00104 if (i > 0) {
00105 #ifdef DEBUG
00106 locDebugFile << "Cloning previous clip " << i << endl;
00107 #endif
00108 C_ClipTag *locClipInTimeRange = inClipTagList->getTag(i - 1);
00109 locClipTagList->addTag(locClipInTimeRange->clone());
00110 }
00111 locAlreadyEncounteredClipInTimeRange = true;
00112 }
00113 #ifdef DEBUG
00114 locDebugFile << "Cloning clip " << i << endl;
00115 #endif
00116 locClipTagList->addTag(locTag->clone());
00117 }
00118 }
00119
00120 #ifdef DEBUG
00121 locDebugFile.close();
00122 #endif
00123 return locClipTagList;
00124 }