diff --git a/CHANGELOG.md b/CHANGELOG.md index d5f080b..7493821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,44 @@ # VXG Mobile SDK Android +### MobileSDK 2.0.305 + + CloudSDK +Version 2.0.305_20221127: +- updated versions of used SDK: + PlayerSDK: 6.96.20221127 + EncoderSDK: 6.13.20221127 +- addec clips API support +- improved APIs for timeline, activity, events, records, thumbnails +- added code snippets in the player example +- fixed a lot of bugs and typos + + PlayerSDK +Version 6.96.20221127: +- updated license list + + EncoderSDK +Version 6.13.20221127: +- updated license list + +### MobileSDK 2.0.304 + + CloudSDK +Version 2.0.304_20221118: +- updated versions of used SDK: + PlayerSDK: 6.96.20221118 +- added fixes for latest Cloud API changes +- fixed issues with playning records on the Android 13 +- improved internal surface switching processing +- added access for new advanced PlayerSDK config settings + + PlayerSDK +Version 6.96.20221118: +- added new advanced config settings: + probesize, fpsprobesize, formatprobesize, max_probe_packets, live_start_index, rtmp_buffer, rtmp_live + + EncoderSDK +Version 6.13.20220824: + ### MobileSDK 2.0.303 CloudSDK diff --git a/CloudSDK/aar/cloudsdk-2.0.303.aar b/CloudSDK/aar/cloudsdk-2.0.305.aar similarity index 95% rename from CloudSDK/aar/cloudsdk-2.0.303.aar rename to CloudSDK/aar/cloudsdk-2.0.305.aar index 0706050..ae42717 100644 Binary files a/CloudSDK/aar/cloudsdk-2.0.303.aar and b/CloudSDK/aar/cloudsdk-2.0.305.aar differ diff --git a/CloudSDK/src/build.gradle b/CloudSDK/src/build.gradle index 08dcb34..66191b7 100644 --- a/CloudSDK/src/build.gradle +++ b/CloudSDK/src/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. ext { - cloudsdk_ver = project.hasProperty('cloudsdk_ver') ? project.getProperty('cloudsdk_ver') : "2.0.303" - playersdk_ver = project.hasProperty('playersdk_ver') ? project.getProperty('playersdk_ver') : "6.96.20220824" + cloudsdk_ver = project.hasProperty('cloudsdk_ver') ? project.getProperty('cloudsdk_ver') : "2.0.305" + playersdk_ver = project.hasProperty('playersdk_ver') ? project.getProperty('playersdk_ver') : "6.96.20221127" } buildscript { diff --git a/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/MainActivity.java b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/MainActivity.java index 26698ae..25337c9 100644 --- a/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/MainActivity.java +++ b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/MainActivity.java @@ -37,6 +37,7 @@ import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; +import com.vxg.cloud.core.CloudCommon.CloudLiveUrlType; import com.vxg.cloud.core.CloudHelpers; import com.vxg.cloudsdk.CloudPlayerSDK; import com.vxg.cloudsdk.CloudSDK; @@ -45,11 +46,18 @@ import com.vxg.cloudsdk.Interfaces.ICloudObject; import com.vxg.cloudsdk.Interfaces.ICloudPlayerCallback; import com.vxg.cloudsdk.Objects.CloudPlayerConfig; +import com.vxg.cloudsdk.streamland_player.snippets.CloudClips; +import com.vxg.cloudsdk.streamland_player.snippets.CloudEvents; +import com.vxg.cloudsdk.streamland_player.snippets.CloudTimelineDays; +import com.vxg.cloudsdk.streamland_player.snippets.CloudTimelineSegments; +import com.vxg.cloudsdk.streamland_player.snippets.CloudTimelineThumbnails; +import com.vxg.cloudsdk.streamland_player.snippets.CloudTimelines; import com.vxg.ui.CloudPlayerView; import com.vxg.ui.TimeLineSet; import java.io.File; import java.util.List; +import java.util.concurrent.Executors; public class MainActivity extends Activity implements OnClickListener, CloudPlayerView.OnCloudPlayerViewChange { @@ -57,6 +65,7 @@ public class MainActivity extends Activity implements OnClickListener, CloudPlay public static AutoCompleteTextView edtId; private Button btnConnect; + private Button btnTestAPI; private Button btnShowTimeline; private Button btnRecord; @@ -179,7 +188,7 @@ public void onDataLoaded(List> data) { } }); - btnShowTimeline =(Button) findViewById(R.id.but_show_timeline); + btnShowTimeline = (Button) findViewById(R.id.but_show_timeline); btnShowTimeline.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -193,7 +202,15 @@ public void onClick(View v) { } }); - btnRecord =(Button) findViewById(R.id.but_record); + btnTestAPI = (Button) findViewById(R.id.but_test_api); + btnTestAPI.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + testAPI(); + } + }); + + btnRecord = (Button) findViewById(R.id.but_record); btnRecord.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -286,7 +303,7 @@ public void onClick(View v) return; } } - + private String getRecordPath() { File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory( @@ -301,6 +318,57 @@ private String getRecordPath() return mediaStorageDir.getPath(); } + private void testAPI() { + // To check the snippets, please uncomment what you are interested in checking. + // The result is in the application logs + // For avoid run network code in main thread with methods *Sync, we use Executors.newSingleThreadExecutor for this test + +// CloudPlayerSDK testSDK = new CloudPlayerSDK(null, null, null); +// testSDK.setSourceForAPIOnly(msAccessToken); +// +// CloudClips clips = new CloudClips(testSDK); +// Executors.newSingleThreadExecutor().submit(clips::printClipsSync); +// Executors.newSingleThreadExecutor().submit(clips::createClipCompleteSync); +// Executors.newSingleThreadExecutor().submit(clips::createClipSync); +// Executors.newSingleThreadExecutor().submit(clips::updateClipsSync); +// Executors.newSingleThreadExecutor().submit(clips::deleteClipsForClipIdSync); +// Executors.newSingleThreadExecutor().submit(clips::printClipsSync); +// Executors.newSingleThreadExecutor().submit(() -> clips.deleteClipsForCameraIdSync(-1)); +// Executors.newSingleThreadExecutor().submit(clips::printClipsSync); +// clips.printClips(); +// clips.createClip(); +// clips.deleteClipsForCameraId(-1); +// +// CloudTimelines timelines = new CloudTimelines(testSDK); +// Executors.newSingleThreadExecutor().submit(timelines::printTimelineSync); +// Executors.newSingleThreadExecutor().submit(timelines::printTimelineWithLimitSync); +// timelines.printTimeline(); +// timelines.printTimelineWithLimit(); +// +// CloudTimelineDays days = new CloudTimelineDays(testSDK); +// Executors.newSingleThreadExecutor().submit(days::printTimelineDaysSync); +// Executors.newSingleThreadExecutor().submit(days::printTimelineDaysWithLimitSync); +// days.printTimelineDays(); +// days.printTimelineDaysWithLimit(); +// +// CloudEvents events = new CloudEvents(testSDK); +// Executors.newSingleThreadExecutor().submit(events::printEventsSync); +// Executors.newSingleThreadExecutor().submit(events::printEventsWithLimitSync); +// events.printEvents(); +// events.printEventsWithLimit(); +// +// CloudTimelineSegments segments = new CloudTimelineSegments(testSDK); +// Executors.newSingleThreadExecutor().submit(segments::printSegmentsSync); +// Executors.newSingleThreadExecutor().submit(segments::printSegmentsWithLimitSync); +// segments.printSegments(); +// segments.printSegmentsWithLimit(); +// +// CloudTimelineThumbnails thumbnails = new CloudTimelineThumbnails(testSDK); +// Executors.newSingleThreadExecutor().submit(thumbnails::printThumbnailsSync); +// Executors.newSingleThreadExecutor().submit(thumbnails::printThumbnailsWithLimitSync); +// thumbnails.printThumbnails(); +// thumbnails.printThumbnailsWithLimit(); + } @Override protected void onDestroy() { diff --git a/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudClips.java b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudClips.java new file mode 100644 index 0000000..4937e96 --- /dev/null +++ b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudClips.java @@ -0,0 +1,350 @@ +package com.vxg.cloudsdk.streamland_player.snippets; + +import android.util.Log; +import android.util.Pair; + +import com.vxg.cloud.core.CloudHelpers; +import com.vxg.cloudsdk.CloudPlayerSDK; +import com.vxg.cloudsdk.Interfaces.ICompletionCallback; +import com.vxg.cloudsdk.Interfaces.IInterruptedCallback; +import com.vxg.cloudsdk.Objects.CloudClip; +import com.vxg.cloudsdk.Objects.CloudTimelineSegment; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; + +// https://web.vaplatform.ru/docs/v2.html#/storage%20(clips) +public class CloudClips { + public final String TAG = CloudClips.class.getSimpleName(); + + private final CloudPlayerSDK playerSDK; + + public CloudClips(CloudPlayerSDK sdk) { + this.playerSDK = sdk; + } + + public void printClips() { + // print available clips + long endClips = CloudHelpers.currentTimestampUTC(); + long startClips = endClips - 1 * 24 * 60 * 60 * 1000; + + String order = "";//""event_time"; + ArrayList> params = new ArrayList<>(); + //params.add(new Pair<>("event_time", "2022-11-08T00:00:01")); + + playerSDK.getClips(startClips, endClips,0, 100, false, order, params, (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList clips = (ArrayList)o_result; + Log.e(TAG, "clips count: " + clips.size()); + for (CloudClip clip : clips) { + Log.e(TAG, "clip: " + CloudHelpers.objectToString(clip)); + } + return 0; + }); + } + + public void printClipsSync() { + // print available clips + long endClips = CloudHelpers.currentTimestampUTC(); + long startClips = endClips - 1 * 24 * 60 * 60 * 1000; + + String order = "";//""event_time"; + ArrayList> params = new ArrayList<>(); + //params.add(new Pair<>("event_time", "2022-11-08T00:00:01")); + + ArrayList clips = playerSDK.getClipsSync(startClips, endClips, + 0, 100, false, order, params); + Log.e(TAG, "clips count: " + clips.size()); + for (CloudClip clip : clips) { + Log.e(TAG, "clip: " + CloudHelpers.objectToString(clip)); + } + } + + + public void clipDescription() { + // get available clips + long endClips = CloudHelpers.currentTimestampUTC(); + long startClips = endClips - 1 * 24 * 60 * 60 * 1000; + + String order = "";//""event_time"; + ArrayList> params = new ArrayList<>(); + //params.add(new Pair<>("event_time", "2022-11-08T00:00:01")); + + ArrayList clips = playerSDK.getClipsSync(startClips, endClips,0, 100, false, order, params); + Log.e(TAG, "clips count: " + clips.size()); + for (CloudClip clip : clips) { + playerSDK.getClipDescription(clip.id, (o_result, result) -> { + if (result != 0) { + return 0; + } + + CloudClip requested = (CloudClip)o_result; + Log.e(TAG, "check creating clip: " + CloudHelpers.objectToString(requested)); + return 0; + }); + } + } + + public void clipDescriptionSync() { + // get available clips + long endClips = CloudHelpers.currentTimestampUTC(); + long startClips = endClips - 1 * 24 * 60 * 60 * 1000; + + String order = "";//""event_time"; + ArrayList> params = new ArrayList<>(); + //params.add(new Pair<>("event_time", "2022-11-08T00:00:01")); + + ArrayList clips = playerSDK.getClipsSync(startClips, endClips,0, 100, false, order, params); + Log.e(TAG, "clips count: " + clips.size()); + for (CloudClip clip : clips) { + CloudClip requested = playerSDK.getClipDescriptionSync(clip.id); + Log.e(TAG, "check creating clip: " + CloudHelpers.objectToString(requested)); + + } + } + + + public void createClipCompleteSync() { + int clipCountGuard = 2; + + // get record segments as source for clip creation + long end = CloudHelpers.currentTimestampUTC(); + long start = end - 1 * 60 * 60 * 1000; + ArrayList segments = playerSDK.getTimelineSegmentsSync(start, end); + Log.e(TAG, "segments count: " + segments.size()); + for (CloudTimelineSegment segment : segments) { + Log.e(TAG, "segment: " + CloudHelpers.objectToString(segment)); + + // create clip + long makeStart = segment.timeStart; + long makeEnd = segment.timeStop; + String title = "createClipComplete_" + CloudHelpers.formatTime(makeStart) + "__" + CloudHelpers.formatTime(makeEnd); + CloudClip requested = playerSDK.createClipSync(title, makeStart, makeEnd, -1, null, 3000, new IInterruptedCallback() { + @Override + public Boolean isInterrupted() { + return false; + } + }); + + Log.e(TAG, "create clip: " + CloudHelpers.objectToString(requested)); + clipCountGuard--; + if (clipCountGuard <=0) { + break; + } + } + + // print available clips clips after creation + //printClips(); + } + + public void createClipSync() { + int clipCountGuard = 2; + + // get record segments as source for clip creation + long end = CloudHelpers.currentTimestampUTC(); + long start = end - 1 * 60 * 60 * 1000; + ArrayList segments = playerSDK.getTimelineSegmentsSync(start, end); + Log.e(TAG, "segments count: " + segments.size()); + for (CloudTimelineSegment segment : segments) { + Log.e(TAG, "segment: " + CloudHelpers.objectToString(segment)); + + // start creating clip + long makeStart = segment.timeStart; + long makeEnd = segment.timeStop; + String title = "createClip_" + CloudHelpers.formatTime(makeStart) + "__" + CloudHelpers.formatTime(makeEnd); + + CloudClip requested = playerSDK.startCreatingClipSync(title, makeStart, makeEnd, -1, null); + Log.e(TAG, "try create clip: " + CloudHelpers.objectToString(requested)); + + // wait for the creation process to complete + while (requested.getStatus() == CloudClip.Status.pending) { + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + } + requested = playerSDK.getClipDescriptionSync(requested.id); + Log.e(TAG, "check creating clip: " + CloudHelpers.objectToString(requested)); + } + + Log.e(TAG, "create clip: " + CloudHelpers.objectToString(requested)); + clipCountGuard--; + if (clipCountGuard <=0) { + break; + } + } + + // print available clips after creation + //printClips(); + } + + public void createClip() { + int clipCountGuard = 1; + + // get record segments as source for clip creation + long end = CloudHelpers.currentTimestampUTC(); + long start = end - 1 * 60 * 60 * 1000; + ArrayList segments = playerSDK.getTimelineSegmentsSync(start, end); + Log.e(TAG, "segments count: " + segments.size()); + for (CloudTimelineSegment segment : segments) { + Log.e(TAG, "segment: " + CloudHelpers.objectToString(segment)); + + // start creating clip + long makeStart = segment.timeStart; + long makeEnd = segment.timeStop; + String title = "createClip_" + CloudHelpers.formatTime(makeStart) + "__" + CloudHelpers.formatTime(makeEnd); + + playerSDK.startCreatingClip(title, makeStart, makeEnd, -1, null, (o_result, result) -> { + if (result != 0) { + return 0; + } + + CloudClip requested = (CloudClip)o_result; + Log.e(TAG, "try create clip: " + CloudHelpers.objectToString(requested)); + + // wait for the creation process to complete + while (requested.getStatus() == CloudClip.Status.pending) { + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + } + requested = playerSDK.getClipDescriptionSync(requested.id); + Log.e(TAG, "check creating clip: " + CloudHelpers.objectToString(requested)); + } + + Log.e(TAG, "create clip: " + CloudHelpers.objectToString(requested)); + return 0; + }); + clipCountGuard--; + if (clipCountGuard <=0) { + break; + } + } + // print available clips after creation + //printClips(); + } + + + public void updateClips() { + // get available clips + long endClips = CloudHelpers.currentTimestampUTC(); + long startClips = endClips - 1 * 24 * 60 * 60 * 1000; + + String order = "";//""event_time"; + ArrayList> params = new ArrayList<>(); + //params.add(new Pair<>("event_time", "2022-11-08T00:00:01")); + + ArrayList clips = playerSDK.getClipsSync(startClips, endClips,0, 100, false, order, params); + Log.e(TAG, "clips count: " + clips.size()); + for (CloudClip clip : clips) { + JSONObject params1 = new JSONObject(); + try { + params1.put("title", clip.title + "_changed"); + } catch (JSONException ignored) {} + + playerSDK.updateStorageClip(clip.id, params1, (o_result, result) -> { + if (result != 0) { + return 0; + } + + CloudClip changed = (CloudClip)o_result; + Log.e(TAG, "updated clip: " + CloudHelpers.objectToString(changed)); + return 0; + }); + } + } + + public void updateClipsSync() { + // get available clips + long endClips = CloudHelpers.currentTimestampUTC(); + long startClips = endClips - 1 * 24 * 60 * 60 * 1000; + + String order = "";//""event_time"; + ArrayList> params = new ArrayList<>(); + //params.add(new Pair<>("event_time", "2022-11-08T00:00:01")); + + ArrayList clips = playerSDK.getClipsSync(startClips, endClips,0, 100, false, order, params); + Log.e(TAG, "clips count: " + clips.size()); + for (CloudClip clip : clips) { + JSONObject params1 = new JSONObject(); + try { + params1.put("title", clip.title + "_changed"); + } catch (JSONException ignored) {} + + CloudClip changed = playerSDK.updateStorageClipSync(clip.id, params1); + Log.e(TAG, "updated clip: " + CloudHelpers.objectToString(changed)); + } + } + + + public void deleteClipsForCameraId(long camId) { + playerSDK.deleteClip(camId, -1, (o_result, result) -> { + Log.e(TAG, "delete clip result: " + result); + return 0; + }); + //printClips(); + } + + public void deleteClipsForCameraIdSync(long camId) { + int resultDelete = playerSDK.deleteClipSync(camId, -1); + Log.e(TAG, "delete clip result: " + resultDelete); + //printClips(); + } + + + public void deleteClipsForClipId() { + int clipCountGuard = 2; + long endClips = CloudHelpers.currentTimestampUTC(); + long startClips = endClips - 1 * 24 * 60 * 60 * 1000; + + String order = "";//""event_time"; + ArrayList> params = new ArrayList<>(); + //params.add(new Pair<>("event_time", "2022-11-08T00:00:01")); + + ArrayList clips = playerSDK.getClipsSync(startClips, endClips, + 0, 100, false, order, params); + Log.e(TAG, "1. clips count: " + clips.size()); + + for (CloudClip clip : clips) { + playerSDK.deleteClip(clip.id, (o_result, result) -> { + Log.e(TAG, "delete clip result: " + result); + return 0; + }); + clipCountGuard--; + if (clipCountGuard <=0) { + break; + } + } + + //printClips(); + } + + public void deleteClipsForClipIdSync() { + int clipCountGuard = 2; + long endClips = CloudHelpers.currentTimestampUTC(); + long startClips = endClips - 1 * 24 * 60 * 60 * 1000; + + String order = "";//""event_time"; + ArrayList> params = new ArrayList<>(); + //params.add(new Pair<>("event_time", "2022-11-08T00:00:01")); + + ArrayList clips = playerSDK.getClipsSync(startClips, endClips, + 0, 100, false, order, params); + Log.e(TAG, "1. clips count: " + clips.size()); + + for (CloudClip clip : clips) { + int resultDelete = playerSDK.deleteClipSync(clip.id); + Log.e(TAG, "delete clip result: " + resultDelete); + clipCountGuard--; + if (clipCountGuard <=0) { + break; + } + } + + //printClips(); + } +} diff --git a/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudEvents.java b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudEvents.java new file mode 100644 index 0000000..c403c79 --- /dev/null +++ b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudEvents.java @@ -0,0 +1,82 @@ +package com.vxg.cloudsdk.streamland_player.snippets; + +import android.util.Log; +import android.util.Pair; + +import com.vxg.cloud.core.CloudHelpers; +import com.vxg.cloudsdk.CloudPlayerSDK; +import com.vxg.cloudsdk.Interfaces.ICompletionCallback; +import com.vxg.cloudsdk.Objects.CloudEvent; +import com.vxg.cloudsdk.Objects.CloudTimeline; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + +// https://web.vaplatform.ru/docs/v2.html#/storage%20(data) +// https://web.vaplatform.ru/docs/v2.html#/storage%20(data)/get_storage_events_ +public class CloudEvents { + public final String TAG = CloudEvents.class.getSimpleName(); + + private final CloudPlayerSDK playerSDK; + + public CloudEvents(CloudPlayerSDK sdk) { + this.playerSDK = sdk; + } + + public void printEvents() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 60 * 60 * 1000; + + playerSDK.getEvents(startTime, endTime, null, (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList events = (ArrayList)o_result; + for (CloudEvent event : events) { + Log.e(TAG, "event: " + CloudHelpers.objectToString(event)); + } + return 0; + }); + } + + public void printEventsSync() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 60 * 60 * 1000; + + ArrayList events = playerSDK.getEventsSync(startTime, endTime, null); + for (CloudEvent event : events) { + Log.e(TAG, "event: " + CloudHelpers.objectToString(event)); + } + } + + + public void printEventsWithLimit() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 60 * 60 * 1000; + + playerSDK.getEvents(startTime, endTime, 0, 10, null, false, "", null, (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList events = (ArrayList)o_result; + for (CloudEvent event : events) { + Log.e(TAG, "event: " + CloudHelpers.objectToString(event)); + } + return 0; + }); + } + + public void printEventsWithLimitSync() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 60 * 60 * 1000; + + ArrayList eventList = new ArrayList<>(Collections.unmodifiableList(Arrays.asList("motion", "sound"))); + ArrayList events = playerSDK.getEventsSync(startTime, endTime, 0, 10, eventList, false, "", null); + for (CloudEvent event : events) { + Log.e(TAG, "event: " + CloudHelpers.objectToString(event)); + } + } +} diff --git a/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineDays.java b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineDays.java new file mode 100644 index 0000000..5d6317e --- /dev/null +++ b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineDays.java @@ -0,0 +1,81 @@ +package com.vxg.cloudsdk.streamland_player.snippets; + +import android.util.Log; + +import com.vxg.cloud.core.CloudHelpers; +import com.vxg.cloudsdk.CloudPlayerSDK; +import com.vxg.cloudsdk.Interfaces.ICompletionCallback; + +import java.util.ArrayList; + +// https://web.vaplatform.ru/docs/v2.html#/storage%20(calendar%20%26%20timeline) +// https://web.vaplatform.ru/docs/v2.html#/storage%20(calendar%20%26%20timeline)/get_storage_activity_ +public class CloudTimelineDays { + public final String TAG = CloudTimelineDays.class.getSimpleName(); + + private final CloudPlayerSDK playerSDK; + + public CloudTimelineDays(CloudPlayerSDK sdk) { + this.playerSDK = sdk; + } + + public void printTimelineDays() { + // print timeline + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 2 * 24 * 60 * 60 * 1000; + + playerSDK.getTimelineDays(false, (ICompletionCallback) (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList days = (ArrayList)o_result; + for (Long day : days) { + Log.e(TAG, "item: " + CloudHelpers.formatTime(day)); + } + return 0; + }); + } + + public void printTimelineDaysSync() { + // print timeline + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 2 * 24 * 60 * 60 * 1000; + + ArrayList days = playerSDK.getTimelineDaysSync(false); + for (Long day : days) { + Log.e(TAG, "item: " + CloudHelpers.formatTime(day)); + } + } + + + public void printTimelineDaysWithLimit() { + // print timeline + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 24 * 60 * 60 * 1000; + + playerSDK.getTimelineDays(startTime, endTime, 0, 10, null, false, false, (ICompletionCallback) (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList days = (ArrayList)o_result; + for (Long day : days) { + Log.e(TAG, "item: " + CloudHelpers.formatTime(day)); + } + return 0; + }); + } + + public void printTimelineDaysWithLimitSync() { + // print timeline + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 2 * 24 * 60 * 60 * 1000; + + ArrayList days = playerSDK.getTimelineDaysSync(startTime, endTime, 0, 10, null, false, false); + for (Long day : days) { + Log.e(TAG, "item: " + CloudHelpers.formatTime(day)); + } + } + +} diff --git a/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineSegments.java b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineSegments.java new file mode 100644 index 0000000..e601a61 --- /dev/null +++ b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineSegments.java @@ -0,0 +1,79 @@ +package com.vxg.cloudsdk.streamland_player.snippets; + +import android.util.Log; + +import com.vxg.cloud.core.CloudHelpers; +import com.vxg.cloudsdk.CloudPlayerSDK; +import com.vxg.cloudsdk.Objects.CloudEvent; +import com.vxg.cloudsdk.Objects.CloudTimelineSegment; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + +// https://web.vaplatform.ru/docs/v2.html#/storage%20(data) +// https://web.vaplatform.ru/docs/v2.html#/storage%20(data)/get_storage_data_ +public class CloudTimelineSegments { + public final String TAG = CloudTimelineSegments.class.getSimpleName(); + + private final CloudPlayerSDK playerSDK; + + public CloudTimelineSegments(CloudPlayerSDK sdk) { + this.playerSDK = sdk; + } + + public void printSegments() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 1 * 60 * 60 * 1000; + + playerSDK.getTimelineSegments(startTime, endTime, (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList segments = (ArrayList)o_result; + for (CloudTimelineSegment segment : segments) { + Log.e(TAG, "segment: " + CloudHelpers.objectToString(segment)); + } + return 0; + }); + } + + public void printSegmentsSync() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 1 * 60 * 60 * 1000; + + ArrayList segments = playerSDK.getTimelineSegmentsSync(startTime, endTime); + for (CloudTimelineSegment segment : segments) { + Log.e(TAG, "segment: " + CloudHelpers.objectToString(segment)); + } + } + + + public void printSegmentsWithLimit() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 60 * 60 * 1000; + + playerSDK.getTimelineSegments(startTime, endTime, 0, 10,false, "", null, (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList segments = (ArrayList)o_result; + for (CloudTimelineSegment segment : segments) { + Log.e(TAG, "segment: " + CloudHelpers.objectToString(segment)); + } + return 0; + }); + } + + public void printSegmentsWithLimitSync() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 60 * 60 * 1000; + + ArrayList segments = playerSDK.getTimelineSegmentsSync(startTime, endTime, 0, 10,false, "", true); + for (CloudTimelineSegment segment : segments) { + Log.e(TAG, "segment: " + CloudHelpers.objectToString(segment)); + } + } +} diff --git a/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineThumbnails.java b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineThumbnails.java new file mode 100644 index 0000000..a5a3f89 --- /dev/null +++ b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelineThumbnails.java @@ -0,0 +1,77 @@ +package com.vxg.cloudsdk.streamland_player.snippets; + +import android.util.Log; + +import com.vxg.cloud.core.CloudHelpers; +import com.vxg.cloudsdk.CloudPlayerSDK; +import com.vxg.cloudsdk.Objects.CloudTimelineSegment; +import com.vxg.cloudsdk.Objects.CloudTimelineThumbnail; + +import java.util.ArrayList; + +// https://web.vaplatform.ru/docs/v2.html#/storage%20(data) +// https://web.vaplatform.ru/docs/v2.html#/storage%20(data)/get_storage_data_ +public class CloudTimelineThumbnails { + public final String TAG = CloudTimelineThumbnails.class.getSimpleName(); + + private final CloudPlayerSDK playerSDK; + + public CloudTimelineThumbnails(CloudPlayerSDK sdk) { + this.playerSDK = sdk; + } + + public void printThumbnails() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 1 * 60 * 60 * 1000; + + playerSDK.getTimelineThumbnails(startTime, endTime, (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList thumbnails = (ArrayList)o_result; + for (CloudTimelineThumbnail thumbnail : thumbnails) { + Log.e(TAG, "thumbnail: " + CloudHelpers.objectToString(thumbnail)); + } + return 0; + }); + } + + public void printThumbnailsSync() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 1 * 60 * 60 * 1000; + + ArrayList thumbnails = playerSDK.getTimelineThumbnailsSync(startTime, endTime); + for (CloudTimelineThumbnail thumbnail : thumbnails) { + Log.e(TAG, "thumbnail: " + CloudHelpers.objectToString(thumbnail)); + } + } + + + public void printThumbnailsWithLimit() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 60 * 60 * 1000; + + playerSDK.getTimelineThumbnails(startTime, endTime, 0, 10,false, "", null, (o_result, result) -> { + if (result != 0) { + return 0; + } + + ArrayList thumbnails = (ArrayList)o_result; + for (CloudTimelineThumbnail thumbnail : thumbnails) { + Log.e(TAG, "thumbnail: " + CloudHelpers.objectToString(thumbnail)); + } + return 0; + }); + } + + public void printThumbnailsWithLimitSync() { + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 60 * 60 * 1000; + + ArrayList thumbnails = playerSDK.getTimelineThumbnailsSync(startTime, endTime, 0, 10,true, "", null); + for (CloudTimelineThumbnail thumbnail : thumbnails) { + Log.e(TAG, "thumbnail: " + CloudHelpers.objectToString(thumbnail)); + } + } +} diff --git a/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelines.java b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelines.java new file mode 100644 index 0000000..e244fbd --- /dev/null +++ b/CloudSDK/src/streamland_player/src/main/java/com/vxg/cloudsdk/streamland_player/snippets/CloudTimelines.java @@ -0,0 +1,83 @@ +package com.vxg.cloudsdk.streamland_player.snippets; + +import android.util.Log; +import android.util.Pair; + +import com.vxg.cloud.core.CloudHelpers; +import com.vxg.cloudsdk.CloudPlayerSDK; + +// https://web.vaplatform.ru/docs/v2.html#/storage%20(calendar%20%26%20timeline) +// https://web.vaplatform.ru/docs/v2.html#/storage%20(calendar%20%26%20timeline)/get_storage_timeline__CAMID__ +public class CloudTimelines { + public final String TAG = CloudTimelines.class.getSimpleName(); + + private final CloudPlayerSDK playerSDK; + + public CloudTimelines(CloudPlayerSDK sdk) { + this.playerSDK = sdk; + } + + public void printTimeline() { + // print timeline + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 2 * 24 * 60 * 60 * 1000; + + playerSDK.getTimeline(startTime, endTime, (o_result, result) -> { + if (result != 0) { + return 0; + } + + com.vxg.cloudsdk.Objects.CloudTimeline timeline = (com.vxg.cloudsdk.Objects.CloudTimeline)o_result; + Log.e(TAG, "timeline: start: " + CloudHelpers.formatTime(timeline.start) + ", end: " + CloudHelpers.formatTime(timeline.end) + ", periods: " + timeline.periods.size()); + for (Pair item : timeline.periods) { + Log.e(TAG, "item: start: " + CloudHelpers.formatTime(item.first) + ", end: " + CloudHelpers.formatTime(item.second)); + } + return 0; + }); + } + + public void printTimelineSync() { + // print timeline + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 2 * 24 * 60 * 60 * 1000; + + com.vxg.cloudsdk.Objects.CloudTimeline timeline = playerSDK.getTimelineSync(startTime, endTime); + Log.e(TAG, "timeline: start: " + CloudHelpers.formatTime(timeline.start) + ", end: " + CloudHelpers.formatTime(timeline.end) + ", periods: " + timeline.periods.size()); + for (Pair item : timeline.periods) { + Log.e(TAG, "item: start: " + CloudHelpers.formatTime(item.first) + ", end: " + CloudHelpers.formatTime(item.second)); + } + } + + + public void printTimelineWithLimit() { + // print timeline + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 24 * 60 * 60 * 1000; + + playerSDK.getTimeline(startTime, endTime, 0, 10, (o_result, result) -> { + if (result != 0) { + return 0; + } + + com.vxg.cloudsdk.Objects.CloudTimeline timeline = (com.vxg.cloudsdk.Objects.CloudTimeline)o_result; + Log.e(TAG, "timeline: start: " + CloudHelpers.formatTime(timeline.start) + ", end: " + CloudHelpers.formatTime(timeline.end) + ", periods: " + timeline.periods.size()); + for (Pair item : timeline.periods) { + Log.e(TAG, "item: start: " + CloudHelpers.formatTime(item.first) + ", end: " + CloudHelpers.formatTime(item.second)); + } + return 0; + }); + } + + public void printTimelineWithLimitSync() { + // print timeline + long endTime = CloudHelpers.currentTimestampUTC(); + long startTime = endTime - 4 * 24 * 60 * 60 * 1000; + + com.vxg.cloudsdk.Objects.CloudTimeline timeline = playerSDK.getTimelineSync(startTime, endTime, 0, 10); + Log.e(TAG, "timeline: start: " + CloudHelpers.formatTime(timeline.start) + ", end: " + CloudHelpers.formatTime(timeline.end) + ", periods: " + timeline.periods.size()); + for (Pair item : timeline.periods) { + Log.e(TAG, "item: start: " + CloudHelpers.formatTime(item.first) + ", end: " + CloudHelpers.formatTime(item.second)); + } + } + +} diff --git a/CloudSDK/src/streamland_player/src/main/res/layout/view_camera_buy_id.xml b/CloudSDK/src/streamland_player/src/main/res/layout/view_camera_buy_id.xml index cf9d8f1..01a414b 100644 --- a/CloudSDK/src/streamland_player/src/main/res/layout/view_camera_buy_id.xml +++ b/CloudSDK/src/streamland_player/src/main/res/layout/view_camera_buy_id.xml @@ -3,6 +3,7 @@ android:id="@+id/main_view" android:layout_width="fill_parent" android:layout_height="fill_parent" > + - - + - + android:orientation="horizontal" >