-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathVideoClipHandler.cs
More file actions
53 lines (42 loc) · 1.82 KB
/
VideoClipHandler.cs
File metadata and controls
53 lines (42 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Data;
using System.Data.SQLite;
using UnityDataTools.Analyzer.SerializedObjects;
using UnityDataTools.FileSystem.TypeTreeReaders;
namespace UnityDataTools.Analyzer.SQLite.Handlers;
public class VideoClipHandler : ISQLiteHandler
{
SQLiteCommand m_InsertCommand;
public void Init(SQLiteConnection db)
{
using var command = new SQLiteCommand(db);
command.CommandText = Properties.Resources.VideoClip;
command.ExecuteNonQuery();
m_InsertCommand = new SQLiteCommand(db);
m_InsertCommand.CommandText = "INSERT INTO video_clips(id, width, height, frame_rate, frame_count) VALUES(@id, @width, @height, @frame_rate, @frame_count)";
m_InsertCommand.Parameters.Add("@id", DbType.Int64);
m_InsertCommand.Parameters.Add("@width", DbType.UInt32);
m_InsertCommand.Parameters.Add("@height", DbType.UInt32);
m_InsertCommand.Parameters.Add("@frame_rate", DbType.Double);
m_InsertCommand.Parameters.Add("@frame_count", DbType.UInt64);
}
public void Process(Context ctx, long objectId, RandomAccessReader reader, out string name, out long streamDataSize)
{
var videoClip = VideoClip.Read(reader);
m_InsertCommand.Parameters["@id"].Value = objectId;
m_InsertCommand.Parameters["@width"].Value = videoClip.Width;
m_InsertCommand.Parameters["@height"].Value = videoClip.Height;
m_InsertCommand.Parameters["@frame_rate"].Value = videoClip.FrameRate;
m_InsertCommand.Parameters["@frame_count"].Value = videoClip.FrameCount;
m_InsertCommand.ExecuteNonQuery();
streamDataSize = (long)videoClip.StreamDataSize;
name = videoClip.Name;
}
public void Finalize(SQLiteConnection db)
{
}
void IDisposable.Dispose()
{
m_InsertCommand.Dispose();
}
}