log->log("JSONServer", Log::DEBUG, "Could not read up to contentLength");
return 0;
}
+ postData[contentLengthI] = '\0';
}
}
bool jsonserver_recinfo(Json::Value& js, const char* postData)
{
- // For now this returns just the string summary of the recording
-
Log* log = Log::getInstance();
log->log("JSONServer", Log::DEBUG, "recinfo");
Recordings.Load(); // probably have to do this
cRecording *recording = Recordings.GetByName(reqfilename);
- if (recording)
- {
- const cRecordingInfo *Info = recording->Info();
- char* summary = (char*)Info->ShortText();
- if (isempty(summary)) summary = (char*)Info->Description();
- js["Result"] = true;
- js["Summary"] = summary;
- }
- else
+ if (!recording)
{
log->log("JSONServer", Log::ERR, "recinfo found no recording");
js["Result"] = false;
- js["Summary"] = "";
- }
+ return true;
+ }
+
+ js["IsNew"] = recording->IsNew();
+ js["LengthInSeconds"] = recording->LengthInSeconds();
+ js["FileSizeMB"] = recording->FileSizeMB();
+ js["Name"] = recording->Name() ? recording->Name() : Json::Value::null;
+ js["Priority"] = recording->Priority();
+ js["LifeTime"] = recording->Lifetime();
+ js["Start"] = (Json::UInt)recording->Start();
+
+ js["ResumePoint"] = 0;
+ cResumeFile ResumeFile(recording->FileName(), recording->IsPesRecording());
+ if (ResumeFile.Read() >= 0) js["ResumePoint"] = ResumeFile.Read();
+
+ js["CurrentlyRecordingStart"] = 0;
+ js["CurrentlyRecordingStop"] = 0;
+ cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName());
+ if (rc)
+ {
+ js["CurrentlyRecordingStart"] = (Json::UInt)rc->Timer()->StartTime();
+ js["CurrentlyRecordingStop"] = (Json::UInt)rc->Timer()->StopTime();
+ }
+ const cRecordingInfo *info = recording->Info();
+ if (info)
+ {
+ js["ChannelName"] = info->ChannelName() ? info->ChannelName() : Json::Value::null;
+ js["Title"] = info->Title() ? info->Title() : Json::Value::null;
+ js["ShortText"] = info->ShortText() ? info->ShortText() : Json::Value::null;
+ js["Description"] = info->Description() ? info->Description() : Json::Value::null;
+
+ const cComponents* components = info->Components();
+ if (!components)
+ {
+ js["Components"] = Json::Value::null;
+ }
+ else
+ {
+ Json::Value jscomponents;
+
+ tComponent* component;
+ for (int i = 0; i < components->NumComponents(); i++)
+ {
+ component = components->Component(i);
+
+ Json::Value oneComponent;
+ oneComponent["Stream"] = component->stream;
+ oneComponent["Type"] = component->type;
+ oneComponent["Language"] = component->language ? component->language : Json::Value::null;
+ oneComponent["Description"] = component->description ? component->description : Json::Value::null;
+ jscomponents.append(oneComponent);
+ }
+
+ js["Components"] = jscomponents;
+ }
+ }
+
+ js["Result"] = true;
return true;
}