Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #36 from revdotcom/feature/addCaptioning
Browse files Browse the repository at this point in the history
Support for AddCaptioning
  • Loading branch information
amhed committed Aug 2, 2015
2 parents 448b4ce + 71ea3b7 commit 0b71e73
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,82 @@ private BrightcoveImage DoAddImage(BrightcoveImage image, FileUploadInfo fileUpl
return RunFilePost<BrightcoveResultContainer<BrightcoveImage>>(parms, fileUploadInfo).Result;
}

#endregion

#region AddLogoOverlay

/// <summary>
/// Adds a logo overlay image to a video.
/// </summary>
/// <param name="logoOverlay">The metadata for the logo overlay you'd like to create (or update).</param>
/// <param name="fileUploadInfo">Information for the file to be uploaded.</param>
/// <param name="videoId">The ID of the video you want to assign a logo overlay to.</param>
/// <returns>The newly created or updated BrightcoveLogoOverlay</returns>
public BrightcoveLogoOverlay AddLogoOverlay(BrightcoveLogoOverlay logoOverlay, FileUploadInfo fileUploadInfo, long videoId)
#endregion

#region AddCaptioning
public BrightcoveCaptioning AddCaptioning(string captionFileUrl, long videoId, string filename)
{
return DoAddCaptioningWithExternalUrl(captionFileUrl, videoId, null, filename);
}

public BrightcoveCaptioning AddCaptioning(string captionFileUrl, string videoReferenceId, string filename)
{
return DoAddCaptioningWithExternalUrl(captionFileUrl, -1, videoReferenceId, filename);
}

private BrightcoveCaptioning DoAddCaptioningWithExternalUrl(string captionFileUrl, long videoId, string videoReferenceId, string filename)
{
string propName;
object propValue;
GetIdValuesForUpload(videoId, videoReferenceId, "video_id", "video_reference_id", out propName, out propValue);

var captionSource = new BrightcoveCaptionSource {
DisplayName = filename,
Url = captionFileUrl
};

BrightcoveParamCollection parms = CreateWriteParamCollection("add_captioning",
methodParams => {
methodParams.Add(propName, propValue);
methodParams.Add("caption_source", captionSource);
methodParams.Add("filename", filename);
});

return RunPost<BrightcoveResultContainer<BrightcoveCaptioning>>(parms).Result;
}

public BrightcoveCaptioning AddCaptioning(FileUploadInfo captionFileUploadInfo, long videoId, string filename)
{
return DoAddCaptioningWithFileUpload(captionFileUploadInfo, videoId, null, filename);
}

public BrightcoveCaptioning AddCaptioning(FileUploadInfo captionFileUploadInfo, string videoReferenceId, string filename)
{
return DoAddCaptioningWithFileUpload(captionFileUploadInfo, -1, videoReferenceId, filename);
}

private BrightcoveCaptioning DoAddCaptioningWithFileUpload(FileUploadInfo captionFileUploadInfo, long videoId, string videoReferenceid, string filename)
{
string propName;
object propValue;
GetIdValuesForUpload(videoId, videoReferenceid, "video_id", "video_reference_id", out propName, out propValue);

var captionSource = new BrightcoveCaptionSource {
DisplayName = filename,
};

BrightcoveParamCollection parms = CreateWriteParamCollection("add_captioning",
methodParams => {
methodParams.Add(propName, propValue);
methodParams.Add("caption_source", captionSource);
methodParams.Add("filename", filename);
});

return RunFilePost<BrightcoveResultContainer<BrightcoveCaptioning>>(parms, captionFileUploadInfo).Result;
}

#endregion

#region AddLogoOverlay

/// <summary>
/// Adds a logo overlay image to a video.
/// </summary>
/// <param name="logoOverlay">The metadata for the logo overlay you'd like to create (or update).</param>
/// <param name="fileUploadInfo">Information for the file to be uploaded.</param>
/// <param name="videoId">The ID of the video you want to assign a logo overlay to.</param>
/// <returns>The newly created or updated BrightcoveLogoOverlay</returns>
public BrightcoveLogoOverlay AddLogoOverlay(BrightcoveLogoOverlay logoOverlay, FileUploadInfo fileUploadInfo, long videoId)
{
return DoAddLogoOverlay(logoOverlay, fileUploadInfo, videoId, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@
<Compile Include="Api\BrightcoveApiConfig.cs" />
<Compile Include="Model\Containers\SortedFieldDictionary.cs" />
<Compile Include="Model\Items\BrightcoveAudioTrack.cs" />
<Compile Include="Model\Items\BrightcoveCaptioning.cs" />
<Compile Include="Model\Items\BrightcoveItem.cs" />
<Compile Include="Model\Items\BrightcoveVideo.cs" />
<Compile Include="Model\Items\BrightcoveCaptionSource.cs" />
<Compile Include="Serialization\IJavaScriptConvertable.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Serialization\BrightcoveItemConverter.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using BrightcoveMapiWrapper.Serialization;
using BrightcoveMapiWrapper.Util;

namespace BrightcoveMapiWrapper.Model.Items
{
/// <summary>
/// A source that provides captions for a video
/// </summary>
/// <remarks>
/// See https://docs.brightcove.com/en/video-cloud/media/references/reference.html#CaptionSource
/// </remarks>
public class BrightcoveCaptionSource : BrightcoveItem, IJavaScriptConvertable
{
/// <summary>
/// A number that uniquely identifies this CaptionSource object,
/// assigned by Video Cloud when this object is created.
/// </summary>
public long? Id { get; private set; }

/// <summary>
/// A Boolean indicating whether or not this CaptionSource is hosted on a remote server,
/// as opposed to hosted by Brightcove.
/// </summary>
public bool IsRemote { get; private set; }

/// <summary>
/// A Boolean indicating whether a CaptionSource is usable.
/// </summary>
public bool Complete { get; private set; }

/// <summary>
/// The name of the caption source, which will be displayed in the Media module.
/// </summary>
public string DisplayName { get; set; }

/// <summary>
/// The complete path to the file.
/// </summary>
public string Url { get; set; }

public IDictionary<string, object> Serialize(JavaScriptSerializer serializer)
{
IDictionary<string, object> serialized = new Dictionary<string, object>();

serialized["complete"] = Complete;
serialized["displayName"] = DisplayName;
serialized["id"] = Id ?? 0;
serialized["isRemote"] = IsRemote;
serialized["url"] = Url;

return serialized;
}

public void Deserialize(IDictionary<string, object> dictionary, JavaScriptSerializer serializer)
{
foreach (string key in dictionary.Keys)
{
switch (key)
{
case "error":
ApiUtil.ThrowIfError(dictionary, key, serializer);
break;

case "complete":
Complete = Convert.ToBoolean(dictionary[key]);
break;

case "displayName":
DisplayName = Convert.ToString(dictionary[key]);
break;

case "id":
Id = Convert.ToInt64(dictionary[key]);
break;

case "isRemote":
IsRemote = Convert.ToBoolean(dictionary[key]);
break;

case "url":
Url = Convert.ToString(dictionary[key]);
break;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using BrightcoveMapiWrapper.Serialization;
using BrightcoveMapiWrapper.Util;

namespace BrightcoveMapiWrapper.Model.Items
{
/// <summary>
/// The Captioning object represents all closed captioning files and metadata assigned to a video.
/// </summary>
/// <remarks>
/// See https://docs.brightcove.com/en/video-cloud/media/references/reference.html#Captioning
/// </remarks>
public class BrightcoveCaptioning : BrightcoveItem, IJavaScriptConvertable
{
/// <summary>
/// A number that uniquely identifies this Captioning object,
/// assigned by VideoCloud when this object is created.
/// </summary>
public long? Id { get; set; }

/// <summary>
/// A set of sources which provide caption.
/// Only one CaptionSource is supported at this time.
/// </summary>
public ICollection<BrightcoveCaptionSource> CaptionSources { get; set; }

public IDictionary<string, object> Serialize(
JavaScriptSerializer serializer)
{
IDictionary<string, object> serialized = new Dictionary<string, object>();

serialized["id"] = Id ?? 0;
serialized["captionSources"] = CaptionSources;

return serialized;
}

public void Deserialize(
IDictionary<string, object> dictionary,
JavaScriptSerializer serializer)
{
foreach (string key in dictionary.Keys)
{
switch (key)
{
case "error":
ApiUtil.ThrowIfError(dictionary, key, serializer);
break;

case "id":
Id = Convert.ToInt64(dictionary[key]);
break;

case "captionSources":
CaptionSources = serializer.ConvertToType<List<BrightcoveCaptionSource>>(dictionary[key]);
break;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ static BrightcoveSerializerFactory()
new BrightcoveItemConverter<BrightcoveResultContainer<BrightcoveItemCollection<BrightcoveVideo>>>(),
new BrightcoveItemConverter<BrightcoveResultContainer<BrightcoveItemCollection<BrightcoveAudioTrack>>>(),
new BrightcoveItemConverter<BrightcoveResultContainer<BrightcoveItemCollection<BrightcovePlaylist>>>(),
new BrightcoveItemConverter<BrightcoveResultContainer<BrightcoveItemCollection<BrightcoveAudioTrackPlaylist>>>()
});
new BrightcoveItemConverter<BrightcoveResultContainer<BrightcoveItemCollection<BrightcoveAudioTrackPlaylist>>>(),

// captioning
new BrightcoveItemConverter<BrightcoveCaptioning>(),
new BrightcoveItemConverter<BrightcoveCaptionSource>(),
new BrightcoveItemConverter<BrightcoveResultContainer<BrightcoveCaptioning>>(),
});
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<tt xml:lang="en" xmlns:tts="http://www.w3.org/ns/ttml#styling" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xmlns="http://www.w3.org/ns/ttml">
<head>
<styling>
<style xml:id="basic" tts:textAlign="center" />
</styling>
<ttm:metadata>
<ttm:title>rev-unconverted.ttml</ttm:title>
</ttm:metadata>
</head>
<body style="basic">
<div>
<p begin="00:00:00.187" end="00:00:02.958">(airplane jet engine)</p>
<p begin="00:00:02.958" end="00:00:07.474">(bright music plays)</p>
<p begin="00:00:09.474" end="00:00:11.120">- Really just stumbled<br />on them through a website</p>
<p begin="00:00:11.120" end="00:00:13.451">where they post medical<br />transcription jobs.</p>
<p begin="00:00:13.451" end="00:00:14.821">This other company was out there,</p>
<p begin="00:00:14.821" end="00:00:17.737">saying, "Hey. We're looking<br />for transcriptionists."</p>
<p begin="00:00:18.413" end="00:00:19.670">I clicked on it.</p>
<p begin="00:00:19.670" end="00:00:21.287">Moved very quickly.</p>
<p begin="00:00:21.287" end="00:00:24.385">Within less than a week,<br />I was already working.</p>
<p begin="00:00:24.385" end="00:00:26.804">- Rev is first and foremost a translation</p>
<p begin="00:00:26.804" end="00:00:28.692">and transcription agency</p>
<p begin="00:00:28.692" end="00:00:32.221">and flexibility is extremely<br />important to me as a student.</p>
<p begin="00:00:32.221" end="00:00:33.932">We can claim jobs as we like,</p>
<p begin="00:00:33.932" end="00:00:37.020">or we can not claim jobs if<br />we don't have time to do them.</p>
<p begin="00:00:37.020" end="00:00:41.534">- I'm getting paid to transcribe these</p>
<p begin="00:00:41.534" end="00:00:43.551">and I'm learning things.</p>
<p begin="00:00:43.551" end="00:00:48.371">I've typed sermons, some<br />great, inspiring sermons.</p>
<p begin="00:00:48.371" end="00:00:51.929">I'm getting to do all this<br />fun stuff and I'm learning</p>
<p begin="00:00:51.929" end="00:00:54.287">and that is just a tremendous experience.</p>
<p begin="00:00:54.287" end="00:00:56.344">- I like the challenge of a word</p>
<p begin="00:00:56.344" end="00:00:59.003">and the most challenging part of my job</p>
<p begin="00:00:59.003" end="00:01:01.647">is when I am transcribing something</p>
<p begin="00:01:01.647" end="00:01:03.902">and they use a word that I don't know.</p>
<p begin="00:01:03.902" end="00:01:07.003">I look it up and I want to<br />make sure I know what it is,</p>
<p begin="00:01:07.003" end="00:01:09.187">that it fits the context of the sentence.</p>
<p begin="00:01:09.187" end="00:01:11.169">Then, I try to - I do this with my kids.</p>
<p begin="00:01:11.169" end="00:01:12.867">I try to use it.</p>
<p begin="00:01:12.867" end="00:01:16.327">- I feel like I've gotten<br />to know Rev as a company</p>
<p begin="00:01:16.327" end="00:01:18.469">and the executives, even, at Rev</p>
<p begin="00:01:18.469" end="00:01:20.854">and it's nice to have that<br />more personal connection,</p>
<p begin="00:01:20.854" end="00:01:22.700">even though it's such a big company.</p>
<p begin="00:01:22.700" end="00:01:23.200">- You know what?</p>
<p begin="00:01:23.200" end="00:01:24.750">They're real people.</p>
<p begin="00:01:24.750" end="00:01:26.371">They're real people and I like that.</p>
<p begin="00:01:26.371" end="00:01:28.559">They're real people and they<br />treat you like a real person.</p>
<p begin="00:01:28.559" end="00:01:29.945">- I really was shocked.</p>
<p begin="00:01:29.945" end="00:01:31.287">I called my husband and said,</p>
<p begin="00:01:31.287" end="00:01:32.390">"Hey, not only did I get a job,</p>
<p begin="00:01:32.390" end="00:01:33.453">"but I've already earned money today.</p>
<p begin="00:01:33.453" end="00:01:34.772">"What do you think of that?"</p>
<p begin="00:01:34.772" end="00:01:38.321">You're always leery<br />about anything that says,</p>
<p begin="00:01:38.321" end="00:01:39.298">"Work from home."</p>
<p begin="00:01:39.298" end="00:01:41.390">It's got a negative connotation to it</p>
<p begin="00:01:41.390" end="00:01:44.000">and everybody thinks it's a scam,</p>
<p begin="00:01:44.000" end="00:01:44.871">but Rev is not.</p>
<p begin="00:01:44.871" end="00:01:45.745">It's not a scam.</p>
<p begin="00:01:45.745" end="00:01:47.160">I truly get paid every week,</p>
<p begin="00:01:47.160" end="00:01:49.871">which is also fantastic.</p>
<p begin="00:01:49.871" end="00:01:52.253">- I did recently purchase<br />a house in Urbana</p>
<p begin="00:01:52.253" end="00:01:54.790">and that was a big commitment,</p>
<p begin="00:01:54.790" end="00:01:58.999">a large part of which was<br />financed by my work with Rev.</p>
<p begin="00:01:58.999" end="00:02:03.541">It's been great, not only in the<br />here and the now for the income,</p>
<p begin="00:02:03.541" end="00:02:06.650">but also as a professional<br />development thing.</p>
<p begin="00:02:06.650" end="00:02:08.957">It's invaluable, as far<br />as what it's going to do</p>
<p begin="00:02:08.957" end="00:02:11.484">for my job security and my options</p>
<p begin="00:02:11.484" end="00:02:15.882">when I get out of school and<br />start looking for full time work.</p>
<p begin="00:02:15.882" end="00:02:19.000">- I don't miss school<br />appointments or school plays</p>
<p begin="00:02:19.000" end="00:02:20.520">or that kind of thing.</p>
<p begin="00:02:20.520" end="00:02:22.867">We don't miss soccer practice,<br />we don't miss soccer games.</p>
<p begin="00:02:22.867" end="00:02:26.717">Those are benefits that<br />you can't get in an office.</p>
<p begin="00:02:26.717" end="00:02:28.466">- I get to work for a living,</p>
<p begin="00:02:28.466" end="00:02:30.919">earn some money, work<br />for a company I like,</p>
<p begin="00:02:30.919" end="00:02:34.887">and pursue my passion, which is writing.</p>
<p begin="00:02:34.887" end="00:02:37.647">I'm not sure how it can<br />get much better than that.</p>
<p begin="00:02:37.647" end="00:02:42.092">(bright music plays)</p>
</div>
</body>
</tt>
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Compile Include="IntegrationTests\VideoRead\SearchVideosCoreTests.cs" />
<Compile Include="IntegrationTests\VideoRead\SearchVideosUrlConstructionTests.cs" />
<Compile Include="IntegrationTests\VideoRead\VideoReadTestBase.cs" />
<Compile Include="IntegrationTests\VideoWrite\AddCaptioningTest.cs" />
<Compile Include="IntegrationTests\VideoWrite\AddImageTests.cs" />
<Compile Include="IntegrationTests\VideoWrite\AddLogoOverlayTests.cs" />
<Compile Include="IntegrationTests\VideoWrite\CreateVideoTests.cs" />
Expand Down Expand Up @@ -139,6 +140,9 @@
<Content Include="Assets\rslane32_-_SAX_STRING.mp3" />
<Content Include="Assets\test-image.png" />
</ItemGroup>
<ItemGroup>
<None Include="Assets\Sample_CaptionFile.dfxp" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Loading

0 comments on commit 0b71e73

Please sign in to comment.