Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Dec 3, 2020
1 parent f682739 commit db109c0
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 45 deletions.
9 changes: 9 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,13 @@
* migration as part of the package.
*/
'track_media_conversions' => true,

/**
* If track_media_conversions is set to true, you may specify the events you would like to fire/track.
* By default, it will track all status updates.
*
* Read more about MediaConvert conversion statuses here:
* https://docs.aws.amazon.com/mediaconvert/latest/ug/mediaconvert_cwe_events.html
*/
'statuses_to_track' => ['complete', 'error', 'new_warning', 'progressing', 'input_information', 'queue_hop'],
];
5 changes: 4 additions & 1 deletion src/Events/ConversionHasCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public function __construct($message)
{
$this->message = $message;

if (config('media-convert.track_media_conversions')) {
if (
config('media-convert.track_media_conversions')
&& in_array('complete', config('media-convert.events_to_track'))
) {
MediaConversion::createActivity($message);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Events/ConversionHasError.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public function __construct($message)
{
$this->message = $message;

if (config('media-convert.track_media_conversions')) {
if (
config('media-convert.track_media_conversions')
&& in_array('error', config('media-convert.events_to_track'))
) {
MediaConversion::createActivity($message);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Events/ConversionHasInputInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public function __construct($message)
{
$this->message = $message;

if (config('media-convert.track_media_conversions')) {
if (
config('media-convert.track_media_conversions')
&& in_array('input_information', config('media-convert.events_to_track'))
) {
MediaConversion::createActivity($message);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Events/ConversionHasNewWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public function __construct($message)
{
$this->message = $message;

if (config('media-convert.track_media_conversions')) {
if (
config('media-convert.track_media_conversions')
&& in_array('new_warning', config('media-convert.events_to_track'))
) {
MediaConversion::createActivity($message);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Events/ConversionHasStatusUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public function __construct($message)
{
$this->message = $message;

if (config('media-convert.track_media_conversions')) {
if (
config('media-convert.track_media_conversions')
&& in_array('status_update', config('media-convert.events_to_track'))
) {
MediaConversion::createActivity($message);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Events/ConversionIsProgressing.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public function __construct($message)
{
$this->message = $message;

if (config('media-convert.track_media_conversions')) {
if (
config('media-convert.track_media_conversions')
&& in_array('progressing', config('media-convert.events_to_track'))
) {
MediaConversion::createActivity($message);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Events/ConversionQueueHop.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public function __construct($message)
{
$this->message = $message;

if (config('media-convert.track_media_conversions')) {
if (
config('media-convert.track_media_conversions')
&& in_array('queue_hop', config('media-convert.events_to_track'))
) {
MediaConversion::createActivity($message);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Models/MediaConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public static function createActivity($message)
{
$status = Str::lower($message['detail']['status']);

$percentage = $message['detail']['jobProgress']['jobPercentComplete'] ?? null;

if ($status === 'complete') {
$percentage = 100;
} else {
$percentage = $message['detail']['jobProgress']['jobPercentComplete'] ?? null;
}

$conversion = new MediaConversion();
Expand Down
72 changes: 36 additions & 36 deletions tests/DummyMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class DummyMessages
'Content-Length' => '1520',
'x-amz-sns-message-type' => 'Notification',
'x-amz-sns-message-id' => '37210acf-236b-59e5-bbb8-52f4f85cd7b3',
'x-amz-sns-topic-arn' => 'arn:aws:sns:us-east-2:923076644019:MediaConvertJobUpdate',
'x-amz-sns-subscription-arn' => 'arn:aws:sns:us-east-2:923076644019:MediaConvertJobUpdate:186ceb0f-9602-4358-8773-168ff19a84e2',
'x-amz-sns-topic-arn' => 'arn:aws:sns:us-east-2:954236614099:MediaConvertJobUpdate',
'x-amz-sns-subscription-arn' => 'arn:aws:sns:us-east-2:954236614099:MediaConvertJobUpdate:186ceb0f-9602-4358-8773-168ff19a84e2',
'Content-Type' => 'text/plain; charset=UTF-8',
'User-Agent' => 'Amazon Simple Notification Service Agent',
'Accept-Encoding' => 'gzip, deflate',
Expand All @@ -28,16 +28,16 @@ class DummyMessages
'id' => 'c5aebd1c-2c6a-ace0-3ab3-9945f986b4c4',
'detail-type' => 'MediaConvert Job State Change',
'source' => 'aws.mediaconvert',
'account' => '923076644019',
'account' => '954236614099',
'time' => '2020-11-28T04:58:31Z',
'region' => 'us-east-2',
'resources' => [
'arn:aws:mediaconvert:us-east-2:923076644019:jobs/1606539508649-2fu0hb',
'arn:aws:mediaconvert:us-east-2:954236614099:jobs/1606539508649-2fu0hb',
],
'detail' => [
'timestamp' => 1606539511533,
'accountId' => '923076644019',
'queue' => 'arn:aws:mediaconvert:us-east-2:923076644019:queues/Default',
'accountId' => '954236614099',
'queue' => 'arn:aws:mediaconvert:us-east-2:954236614099:queues/Default',
'jobId' => '1606539508649-2fu0hb',
'status' => 'PROGRESSING',
'userMetadata' => [
Expand All @@ -52,16 +52,16 @@ class DummyMessages
'id' => '810b18d6-8abd-03dd-5e1d-b0c52f387a05',
'detail-type' => 'MediaConvert Job State Change',
'source' => 'aws.mediaconvert',
'account' => '923076644019',
'account' => '954236614099',
'time' => '2020-11-28T04:58:34Z',
'region' => 'us-east-2',
'resources' => [
'arn:aws:mediaconvert:us-east-2:923076644019:jobs/1606539508649-2fu0hb',
'arn:aws:mediaconvert:us-east-2:954236614099:jobs/1606539508649-2fu0hb',
],
'detail' => [
'timestamp' => 1606539514554,
'accountId' => '923076644019',
'queue' => 'arn:aws:mediaconvert:us-east-2:923076644019:queues/Default',
'accountId' => '954236614099',
'queue' => 'arn:aws:mediaconvert:us-east-2:954236614099:queues/Default',
'jobId' => '1606539508649-2fu0hb',
'status' => 'STATUS_UPDATE',
'userMetadata' => [
Expand Down Expand Up @@ -96,16 +96,16 @@ class DummyMessages
'id' => '7f0eae16-c6d9-5511-0f77-93d2cbead642',
'detail-type' => 'MediaConvert Job State Change',
'source' => 'aws.mediaconvert',
'account' => '923076644019',
'account' => '954236614099',
'time' => '2020-11-28T04:59:51Z',
'region' => 'us-east-2',
'resources' => [
'arn:aws:mediaconvert:us-east-2:923076644019:jobs/1606539508649-2fu0hb',
'arn:aws:mediaconvert:us-east-2:954236614099:jobs/1606539508649-2fu0hb',
],
'detail' => [
'timestamp' => 1606539591681,
'accountId' => '923076644019',
'queue' => 'arn:aws:mediaconvert:us-east-2:923076644019:queues/Default',
'accountId' => '954236614099',
'queue' => 'arn:aws:mediaconvert:us-east-2:954236614099:queues/Default',
'jobId' => '1606539508649-2fu0hb',
'status' => 'STATUS_UPDATE',
'userMetadata' => [
Expand Down Expand Up @@ -139,16 +139,16 @@ class DummyMessages
'id' => '3b9aa7e1-45ab-cf2a-1787-913f4452d16b',
'detail-type' => 'MediaConvert Job State Change',
'source' => 'aws.mediaconvert',
'account' => '923076644019',
'account' => '954236614099',
'time' => '2020-11-28T05:00:03Z',
'region' => 'us-east-2',
'resources' => [
'arn:aws:mediaconvert:us-east-2:923076644019:jobs/1606539508649-2fu0hb',
'arn:aws:mediaconvert:us-east-2:954236614099:jobs/1606539508649-2fu0hb',
],
'detail' => [
'timestamp' => 1606539603045,
'accountId' => '923076644019',
'queue' => 'arn:aws:mediaconvert:us-east-2:923076644019:queues/Default',
'accountId' => '954236614099',
'queue' => 'arn:aws:mediaconvert:us-east-2:954236614099:queues/Default',
'jobId' => '1606539508649-2fu0hb',
'status' => 'COMPLETE',
'userMetadata' => [
Expand All @@ -172,7 +172,7 @@ class DummyMessages
'outputDetails' => [
[
'outputFilePaths' => [
's3://meema-stage/chris/1/isI2oN3/hls/Raindrops_Videvo_1.m3u8',
's3://meema-stage/some/path/isI2oN3/hls/Raindrops_Videvo_1.m3u8',
],
'durationInMs' => 58975,
'videoDetails' => [
Expand All @@ -182,7 +182,7 @@ class DummyMessages
],
[
'outputFilePaths' => [
's3://meema-stage/chris/1/isI2oN3/hls/Raindrops_Videvo_2.m3u8',
's3://meema-stage/some/path/isI2oN3/hls/Raindrops_Videvo_2.m3u8',
],
'durationInMs' => 58975,
'videoDetails' => [
Expand All @@ -192,7 +192,7 @@ class DummyMessages
],
[
'outputFilePaths' => [
's3://meema-stage/chris/1/isI2oN3/hls/Raindrops_Videvo_3.m3u8',
's3://meema-stage/some/path/isI2oN3/hls/Raindrops_Videvo_3.m3u8',
],
'durationInMs' => 58975,
'videoDetails' => [
Expand All @@ -202,7 +202,7 @@ class DummyMessages
],
[
'outputFilePaths' => [
's3://meema-stage/chris/1/isI2oN3/hls/Raindrops_Videvo_4.m3u8',
's3://meema-stage/some/path/isI2oN3/hls/Raindrops_Videvo_4.m3u8',
],
'durationInMs' => 58975,
'videoDetails' => [
Expand All @@ -212,7 +212,7 @@ class DummyMessages
],
[
'outputFilePaths' => [
's3://meema-stage/chris/1/isI2oN3/hls/Raindrops_Videvo_5.m3u8',
's3://meema-stage/some/path/isI2oN3/hls/Raindrops_Videvo_5.m3u8',
],
'durationInMs' => 58975,
'videoDetails' => [
Expand All @@ -222,7 +222,7 @@ class DummyMessages
],
[
'outputFilePaths' => [
's3://meema-stage/chris/1/isI2oN3/hls/Raindrops_Videvo_6.m3u8',
's3://meema-stage/some/path/isI2oN3/hls/Raindrops_Videvo_6.m3u8',
],
'durationInMs' => 58975,
'videoDetails' => [
Expand All @@ -232,15 +232,15 @@ class DummyMessages
],
],
'playlistFilePaths' => [
's3://meema-stage/chris/1/isI2oN3/hls/Raindrops_Videvo.m3u8',
's3://meema-stage/some/path/isI2oN3/hls/Raindrops_Videvo.m3u8',
],
'type' => 'HLS_GROUP',
],
[
'outputDetails' => [
[
'outputFilePaths' => [
's3://meema-stage/chris/1/isI2oN3/mp4/Raindrops_Videvo.mp4',
's3://meema-stage/some/path/isI2oN3/mp4/Raindrops_Videvo.mp4',
],
'durationInMs' => 58975,
'videoDetails' => [
Expand All @@ -260,16 +260,16 @@ class DummyMessages
'id' => 'e9ebf388-8936-bd57-64e3-c2c1f1d78897',
'detail-type' => 'MediaConvert Job State Change',
'source' => 'aws.mediaconvert',
'account' => '923076644019',
'account' => '954236614099',
'time' => '2020-11-28T05:00:02Z',
'region' => 'us-east-2',
'resources' => [
'arn:aws:mediaconvert:us-east-2:923076644019:jobs/1606539508649-2fu0hb',
'arn:aws:mediaconvert:us-east-2:954236614099:jobs/1606539508649-2fu0hb',
],
'detail' => [
'timestamp' => 1606539602895,
'accountId' => '923076644019',
'queue' => 'arn:aws:mediaconvert:us-east-2:923076644019:queues/Default',
'accountId' => '954236614099',
'queue' => 'arn:aws:mediaconvert:us-east-2:954236614099:queues/Default',
'jobId' => '1606539508649-2fu0hb',
'status' => 'INPUT_INFORMATION',
'userMetadata' => [
Expand All @@ -279,7 +279,7 @@ class DummyMessages
'inputDetails' => [
[
'id' => 1,
'uri' => 's3://meema-stage/chris/1/isI2oN3/Raindrops_Videvo.mp4',
'uri' => 's3://meema-stage/some/path/isI2oN3/Raindrops_Videvo.mp4',
'video' => [
[
'bitDepth' => 8,
Expand All @@ -305,20 +305,20 @@ class DummyMessages
'id' => '916792ce-208f-d04a-db2f-a573cf9b08bd',
'detail-type' => 'MediaConvert Job State Change',
'source' => 'aws.mediaconvert',
'account' => '923076644019',
'account' => '954236614099',
'time' => '2020-11-28T05:56:51Z',
'region' => 'us-east-2',
'resources' => [
'arn:aws:mediaconvert:us-east-2:923076644019:jobs/1606542703411-00h7yw',
'arn:aws:mediaconvert:us-east-2:954236614099:jobs/1606542703411-00h7yw',
],
'detail' => [
'timestamp' => 1606543011394,
'accountId' => '923076644019',
'queue' => 'arn:aws:mediaconvert:us-east-2:923076644019:queues/Default',
'accountId' => '954236614099',
'queue' => 'arn:aws:mediaconvert:us-east-2:954236614099:queues/Default',
'jobId' => '1606542703411-00h7yw',
'status' => 'ERROR',
'errorCode' => 1404,
'errorMessage' => 'Unable to open input file [s3://meema-stage/chris/1/AoTef8Z/Raindrops_Videvo.mp4]: [Failed probe/open: [Failed to read data: HeadObject failed]]',
'errorMessage' => 'Unable to open input file [s3://meema-stage/some/path/AoTef8Z/Raindrops_Videvo.mp4]: [Failed probe/open: [Failed to read data: HeadObject failed]]',
'userMetadata' => [
'model_id' => '23',
'hello' => 'world',
Expand Down

0 comments on commit db109c0

Please sign in to comment.