Added new debug methods, and refactored the ReaderBase and WriterBase to better utilize the base class constructor. Also fixed some FFMpegReader issues related to seeking and determining when frames are actually ready.

This commit is contained in:
Jonathan Thomas
2014-08-27 09:44:27 -05:00
parent 66dfed502b
commit cc7a0f41e8
17 changed files with 321 additions and 89 deletions

View File

@@ -29,9 +29,10 @@
using namespace openshot;
// Initialize the values of the FileInfo struct
void WriterBase::InitFileInfo()
// Constructor
WriterBase::WriterBase()
{
// Initialized writer info
info.has_video = false;
info.has_audio = false;
info.duration = 0.0;
@@ -55,6 +56,74 @@ void WriterBase::InitFileInfo()
info.channels = 0;
info.audio_stream_index = -1;
info.audio_timebase = Fraction();
// Initialize debug
debug = false;
}
// Output debug information as JSON
string WriterBase::OutputDebugJSON()
{
// Return formatted string
return debug_root.toStyledString();
}
// Append debug information as JSON
void WriterBase::AppendDebugItem(Json::Value debug_item)
{
// Append item to root array
debug_root.append(debug_item);
}
// Append debug information as JSON
void WriterBase::AppendDebugMethod(string method_name, string arg1_name, int arg1_value,
string arg2_name, int arg2_value,
string arg3_name, int arg3_value,
string arg4_name, int arg4_value,
string arg5_name, int arg5_value,
string arg6_name, int arg6_value)
{
if (!debug)
// Don't do anything
return;
Json::Value debug_item;
debug_item["method"] = method_name;
// Output to standard output
cout << "Debug: Method: " << method_name << " (";
// Add attributes to method JSON
if (arg1_name.length() > 0) {
debug_item[arg1_name] = arg1_value;
cout << arg1_name << "=" << arg1_value;
}
if (arg2_name.length() > 0) {
debug_item[arg2_name] = arg2_value;
cout << ", " << arg2_name << "=" << arg2_value;
}
if (arg3_name.length() > 0) {
debug_item[arg3_name] = arg3_value;
cout << ", " << arg3_name << "=" << arg3_value;
}
if (arg4_name.length() > 0) {
debug_item[arg4_name] = arg4_value;
cout << ", " << arg4_name << "=" << arg4_value;
}
if (arg5_name.length() > 0) {
debug_item[arg5_name] = arg5_value;
cout << ", " << arg5_name << "=" << arg5_value;
}
if (arg6_name.length() > 0) {
debug_item[arg6_name] = arg6_value;
cout << ", " << arg6_name << "=" << arg6_value;
}
// Output to standard output
cout << ")" << endl;
// Append method to root array
debug_root.append(debug_item);
}
// This method copy's the info struct of a reader, and sets the writer with the same info