aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
diff options
context:
space:
mode:
authorArtiume <siderite@gmail.com>2020-01-09 12:14:54 -0500
committerGitHub <noreply@github.com>2020-01-09 12:14:54 -0500
commita40cb7bbd865ec3a693c74669dcc341ecac85169 (patch)
tree85aa8a335a122d87608aef3afa3ed07125722803 /MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
parent5b559979845a1c050176e3083e6307e56b43182c (diff)
parent162c1ac7b7fde0e4929cf262b0f275e3eb15524c (diff)
Merge pull request #7 from jellyfin/master
nightly
Diffstat (limited to 'MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs231
1 files changed, 136 insertions, 95 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 54d02fc9f..bd89c6cae 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -8,7 +8,6 @@ using System.Xml;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo;
@@ -41,21 +40,25 @@ namespace MediaBrowser.MediaEncoding.Probing
FFProbeHelpers.NormalizeFFProbeResult(data);
SetSize(data, info);
- var internalStreams = data.streams ?? new MediaStreamInfo[] { };
+ var internalStreams = data.Streams ?? new MediaStreamInfo[] { };
- info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.format))
+ info.MediaStreams = internalStreams.Select(s => GetMediaStream(isAudio, s, data.Format))
.Where(i => i != null)
// Drop subtitle streams if we don't know the codec because it will just cause failures if we don't know how to handle them
.Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec))
.ToList();
- if (data.format != null)
+ info.MediaAttachments = internalStreams.Select(s => GetMediaAttachment(s))
+ .Where(i => i != null)
+ .ToList();
+
+ if (data.Format != null)
{
- info.Container = NormalizeFormat(data.format.format_name);
+ info.Container = NormalizeFormat(data.Format.FormatName);
- if (!string.IsNullOrEmpty(data.format.bit_rate))
+ if (!string.IsNullOrEmpty(data.Format.BitRate))
{
- if (int.TryParse(data.format.bit_rate, NumberStyles.Any, _usCulture, out var value))
+ if (int.TryParse(data.Format.BitRate, NumberStyles.Any, _usCulture, out var value))
{
info.Bitrate = value;
}
@@ -65,22 +68,22 @@ namespace MediaBrowser.MediaEncoding.Probing
var tags = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
var tagStreamType = isAudio ? "audio" : "video";
- if (data.streams != null)
+ if (data.Streams != null)
{
- var tagStream = data.streams.FirstOrDefault(i => string.Equals(i.codec_type, tagStreamType, StringComparison.OrdinalIgnoreCase));
+ var tagStream = data.Streams.FirstOrDefault(i => string.Equals(i.CodecType, tagStreamType, StringComparison.OrdinalIgnoreCase));
- if (tagStream != null && tagStream.tags != null)
+ if (tagStream != null && tagStream.Tags != null)
{
- foreach (var pair in tagStream.tags)
+ foreach (var pair in tagStream.Tags)
{
tags[pair.Key] = pair.Value;
}
}
}
- if (data.format != null && data.format.tags != null)
+ if (data.Format != null && data.Format.Tags != null)
{
- foreach (var pair in data.format.tags)
+ foreach (var pair in data.Format.Tags)
{
tags[pair.Key] = pair.Value;
}
@@ -153,9 +156,9 @@ namespace MediaBrowser.MediaEncoding.Probing
FetchFromItunesInfo(itunesXml, info);
}
- if (data.format != null && !string.IsNullOrEmpty(data.format.duration))
+ if (data.Format != null && !string.IsNullOrEmpty(data.Format.Duration))
{
- info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.format.duration, _usCulture)).Ticks;
+ info.RunTimeTicks = TimeSpan.FromSeconds(double.Parse(data.Format.Duration, _usCulture)).Ticks;
}
FetchWtvInfo(info, data);
@@ -514,6 +517,39 @@ namespace MediaBrowser.MediaEncoding.Probing
}
/// <summary>
+ /// Converts ffprobe stream info to our MediaAttachment class
+ /// </summary>
+ /// <param name="streamInfo">The stream info.</param>
+ /// <returns>MediaAttachments.</returns>
+ private MediaAttachment GetMediaAttachment(MediaStreamInfo streamInfo)
+ {
+ if (!string.Equals(streamInfo.CodecType, "attachment", StringComparison.OrdinalIgnoreCase))
+ {
+ return null;
+ }
+
+ var attachment = new MediaAttachment
+ {
+ Codec = streamInfo.CodecName,
+ Index = streamInfo.Index
+ };
+
+ if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString))
+ {
+ attachment.CodecTag = streamInfo.CodecTagString;
+ }
+
+ if (streamInfo.Tags != null)
+ {
+ attachment.FileName = GetDictionaryValue(streamInfo.Tags, "filename");
+ attachment.MimeType = GetDictionaryValue(streamInfo.Tags, "mimetype");
+ attachment.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
+ }
+
+ return attachment;
+ }
+
+ /// <summary>
/// Converts ffprobe stream info to our MediaStream class
/// </summary>
/// <param name="isAudio">if set to <c>true</c> [is info].</param>
@@ -523,7 +559,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private MediaStream GetMediaStream(bool isAudio, MediaStreamInfo streamInfo, MediaFormatInfo formatInfo)
{
// These are mp4 chapters
- if (string.Equals(streamInfo.codec_name, "mov_text", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(streamInfo.CodecName, "mov_text", StringComparison.OrdinalIgnoreCase))
{
// Edit: but these are also sometimes subtitles?
//return null;
@@ -531,71 +567,71 @@ namespace MediaBrowser.MediaEncoding.Probing
var stream = new MediaStream
{
- Codec = streamInfo.codec_name,
- Profile = streamInfo.profile,
- Level = streamInfo.level,
- Index = streamInfo.index,
- PixelFormat = streamInfo.pix_fmt,
- NalLengthSize = streamInfo.nal_length_size,
- TimeBase = streamInfo.time_base,
- CodecTimeBase = streamInfo.codec_time_base
+ Codec = streamInfo.CodecName,
+ Profile = streamInfo.Profile,
+ Level = streamInfo.Level,
+ Index = streamInfo.Index,
+ PixelFormat = streamInfo.PixelFormat,
+ NalLengthSize = streamInfo.NalLengthSize,
+ TimeBase = streamInfo.TimeBase,
+ CodecTimeBase = streamInfo.CodecTimeBase
};
- if (string.Equals(streamInfo.is_avc, "true", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(streamInfo.is_avc, "1", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(streamInfo.IsAvc, "true", StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(streamInfo.IsAvc, "1", StringComparison.OrdinalIgnoreCase))
{
stream.IsAVC = true;
}
- else if (string.Equals(streamInfo.is_avc, "false", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(streamInfo.is_avc, "0", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(streamInfo.IsAvc, "false", StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(streamInfo.IsAvc, "0", StringComparison.OrdinalIgnoreCase))
{
stream.IsAVC = false;
}
- if (!string.IsNullOrWhiteSpace(streamInfo.field_order) && !string.Equals(streamInfo.field_order, "progressive", StringComparison.OrdinalIgnoreCase))
+ if (!string.IsNullOrWhiteSpace(streamInfo.FieldOrder) && !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase))
{
stream.IsInterlaced = true;
}
// Filter out junk
- if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string) && streamInfo.codec_tag_string.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1)
+ if (!string.IsNullOrWhiteSpace(streamInfo.CodecTagString) && streamInfo.CodecTagString.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1)
{
- stream.CodecTag = streamInfo.codec_tag_string;
+ stream.CodecTag = streamInfo.CodecTagString;
}
- if (streamInfo.tags != null)
+ if (streamInfo.Tags != null)
{
- stream.Language = GetDictionaryValue(streamInfo.tags, "language");
- stream.Comment = GetDictionaryValue(streamInfo.tags, "comment");
- stream.Title = GetDictionaryValue(streamInfo.tags, "title");
+ stream.Language = GetDictionaryValue(streamInfo.Tags, "language");
+ stream.Comment = GetDictionaryValue(streamInfo.Tags, "comment");
+ stream.Title = GetDictionaryValue(streamInfo.Tags, "title");
}
- if (string.Equals(streamInfo.codec_type, "audio", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(streamInfo.CodecType, "audio", StringComparison.OrdinalIgnoreCase))
{
stream.Type = MediaStreamType.Audio;
- stream.Channels = streamInfo.channels;
+ stream.Channels = streamInfo.Channels;
- if (!string.IsNullOrEmpty(streamInfo.sample_rate))
+ if (!string.IsNullOrEmpty(streamInfo.SampleRate))
{
- if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out var value))
+ if (int.TryParse(streamInfo.SampleRate, NumberStyles.Any, _usCulture, out var value))
{
stream.SampleRate = value;
}
}
- stream.ChannelLayout = ParseChannelLayout(streamInfo.channel_layout);
+ stream.ChannelLayout = ParseChannelLayout(streamInfo.ChannelLayout);
- if (streamInfo.bits_per_sample > 0)
+ if (streamInfo.BitsPerSample > 0)
{
- stream.BitDepth = streamInfo.bits_per_sample;
+ stream.BitDepth = streamInfo.BitsPerSample;
}
- else if (streamInfo.bits_per_raw_sample > 0)
+ else if (streamInfo.BitsPerRawSample > 0)
{
- stream.BitDepth = streamInfo.bits_per_raw_sample;
+ stream.BitDepth = streamInfo.BitsPerRawSample;
}
}
- else if (string.Equals(streamInfo.codec_type, "subtitle", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(streamInfo.CodecType, "subtitle", StringComparison.OrdinalIgnoreCase))
{
stream.Type = MediaStreamType.Subtitle;
stream.Codec = NormalizeSubtitleCodec(stream.Codec);
@@ -603,14 +639,14 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.localizedDefault = _localization.GetLocalizedString("Default");
stream.localizedForced = _localization.GetLocalizedString("Forced");
}
- else if (string.Equals(streamInfo.codec_type, "video", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(streamInfo.CodecType, "video", StringComparison.OrdinalIgnoreCase))
{
stream.Type = isAudio || string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase) || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase) || string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase)
? MediaStreamType.EmbeddedImage
: MediaStreamType.Video;
- stream.AverageFrameRate = GetFrameRate(streamInfo.avg_frame_rate);
- stream.RealFrameRate = GetFrameRate(streamInfo.r_frame_rate);
+ stream.AverageFrameRate = GetFrameRate(streamInfo.AverageFrameRate);
+ stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
if (isAudio || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase) ||
string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase))
@@ -635,17 +671,17 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.Type = MediaStreamType.Video;
}
- stream.Width = streamInfo.width;
- stream.Height = streamInfo.height;
+ stream.Width = streamInfo.Width;
+ stream.Height = streamInfo.Height;
stream.AspectRatio = GetAspectRatio(streamInfo);
- if (streamInfo.bits_per_sample > 0)
+ if (streamInfo.BitsPerSample > 0)
{
- stream.BitDepth = streamInfo.bits_per_sample;
+ stream.BitDepth = streamInfo.BitsPerSample;
}
- else if (streamInfo.bits_per_raw_sample > 0)
+ else if (streamInfo.BitsPerRawSample > 0)
{
- stream.BitDepth = streamInfo.bits_per_raw_sample;
+ stream.BitDepth = streamInfo.BitsPerRawSample;
}
//stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", StringComparison.OrdinalIgnoreCase) ||
@@ -653,11 +689,11 @@ namespace MediaBrowser.MediaEncoding.Probing
// string.Equals(stream.AspectRatio, "2.40:1", StringComparison.OrdinalIgnoreCase);
// http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
- stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", StringComparison.OrdinalIgnoreCase);
+ stream.IsAnamorphic = string.Equals(streamInfo.SampleAspectRatio, "0:1", StringComparison.OrdinalIgnoreCase);
- if (streamInfo.refs > 0)
+ if (streamInfo.Refs > 0)
{
- stream.RefFrames = streamInfo.refs;
+ stream.RefFrames = streamInfo.Refs;
}
}
else
@@ -668,18 +704,18 @@ namespace MediaBrowser.MediaEncoding.Probing
// Get stream bitrate
var bitrate = 0;
- if (!string.IsNullOrEmpty(streamInfo.bit_rate))
+ if (!string.IsNullOrEmpty(streamInfo.BitRate))
{
- if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out var value))
+ if (int.TryParse(streamInfo.BitRate, NumberStyles.Any, _usCulture, out var value))
{
bitrate = value;
}
}
- if (bitrate == 0 && formatInfo != null && !string.IsNullOrEmpty(formatInfo.bit_rate) && stream.Type == MediaStreamType.Video)
+ if (bitrate == 0 && formatInfo != null && !string.IsNullOrEmpty(formatInfo.BitRate) && stream.Type == MediaStreamType.Video)
{
// If the stream info doesn't have a bitrate get the value from the media format info
- if (int.TryParse(formatInfo.bit_rate, NumberStyles.Any, _usCulture, out var value))
+ if (int.TryParse(formatInfo.BitRate, NumberStyles.Any, _usCulture, out var value))
{
bitrate = value;
}
@@ -690,14 +726,18 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.BitRate = bitrate;
}
- if (streamInfo.disposition != null)
+ var disposition = streamInfo.Disposition;
+ if (disposition != null)
{
- var isDefault = GetDictionaryValue(streamInfo.disposition, "default");
- var isForced = GetDictionaryValue(streamInfo.disposition, "forced");
-
- stream.IsDefault = string.Equals(isDefault, "1", StringComparison.OrdinalIgnoreCase);
+ if (disposition.GetValueOrDefault("default") == 1)
+ {
+ stream.IsDefault = true;
+ }
- stream.IsForced = string.Equals(isForced, "1", StringComparison.OrdinalIgnoreCase);
+ if (disposition.GetValueOrDefault("forced") == 1)
+ {
+ stream.IsForced = true;
+ }
}
NormalizeStreamTitle(stream);
@@ -724,7 +764,7 @@ namespace MediaBrowser.MediaEncoding.Probing
/// <param name="tags">The tags.</param>
/// <param name="key">The key.</param>
/// <returns>System.String.</returns>
- private string GetDictionaryValue(Dictionary<string, string> tags, string key)
+ private string GetDictionaryValue(IReadOnlyDictionary<string, string> tags, string key)
{
if (tags == null)
{
@@ -747,7 +787,7 @@ namespace MediaBrowser.MediaEncoding.Probing
private string GetAspectRatio(MediaStreamInfo info)
{
- var original = info.display_aspect_ratio;
+ var original = info.DisplayAspectRatio;
var parts = (original ?? string.Empty).Split(':');
if (!(parts.Length == 2 &&
@@ -756,8 +796,8 @@ namespace MediaBrowser.MediaEncoding.Probing
width > 0 &&
height > 0))
{
- width = info.width;
- height = info.height;
+ width = info.Width;
+ height = info.Height;
}
if (width > 0 && height > 0)
@@ -850,20 +890,20 @@ namespace MediaBrowser.MediaEncoding.Probing
private void SetAudioRuntimeTicks(InternalMediaInfoResult result, MediaInfo data)
{
- if (result.streams != null)
+ if (result.Streams != null)
{
// Get the first info stream
- var stream = result.streams.FirstOrDefault(s => string.Equals(s.codec_type, "audio", StringComparison.OrdinalIgnoreCase));
+ var stream = result.Streams.FirstOrDefault(s => string.Equals(s.CodecType, "audio", StringComparison.OrdinalIgnoreCase));
if (stream != null)
{
// Get duration from stream properties
- var duration = stream.duration;
+ var duration = stream.Duration;
// If it's not there go into format properties
if (string.IsNullOrEmpty(duration))
{
- duration = result.format.duration;
+ duration = result.Format.Duration;
}
// If we got something, parse it
@@ -877,11 +917,11 @@ namespace MediaBrowser.MediaEncoding.Probing
private void SetSize(InternalMediaInfoResult data, MediaInfo info)
{
- if (data.format != null)
+ if (data.Format != null)
{
- if (!string.IsNullOrEmpty(data.format.size))
+ if (!string.IsNullOrEmpty(data.Format.Size))
{
- info.Size = long.Parse(data.format.size, _usCulture);
+ info.Size = long.Parse(data.Format.Size, _usCulture);
}
else
{
@@ -1194,16 +1234,16 @@ namespace MediaBrowser.MediaEncoding.Probing
{
var info = new ChapterInfo();
- if (chapter.tags != null)
+ if (chapter.Tags != null)
{
- if (chapter.tags.TryGetValue("title", out string name))
+ if (chapter.Tags.TryGetValue("title", out string name))
{
info.Name = name;
}
}
// Limit accuracy to milliseconds to match xml saving
- var secondsString = chapter.start_time;
+ var secondsString = chapter.StartTime;
if (double.TryParse(secondsString, NumberStyles.Any, CultureInfo.InvariantCulture, out var seconds))
{
@@ -1218,12 +1258,12 @@ namespace MediaBrowser.MediaEncoding.Probing
private void FetchWtvInfo(MediaInfo video, InternalMediaInfoResult data)
{
- if (data.format == null || data.format.tags == null)
+ if (data.Format == null || data.Format.Tags == null)
{
return;
}
- var genres = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/Genre");
+ var genres = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/Genre");
if (!string.IsNullOrWhiteSpace(genres))
{
@@ -1239,14 +1279,14 @@ namespace MediaBrowser.MediaEncoding.Probing
}
}
- var officialRating = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/ParentalRating");
+ var officialRating = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/ParentalRating");
if (!string.IsNullOrWhiteSpace(officialRating))
{
video.OfficialRating = officialRating;
}
- var people = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaCredits");
+ var people = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/MediaCredits");
if (!string.IsNullOrEmpty(people))
{
@@ -1256,7 +1296,7 @@ namespace MediaBrowser.MediaEncoding.Probing
.ToArray();
}
- var year = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime");
+ var year = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/OriginalReleaseTime");
if (!string.IsNullOrWhiteSpace(year))
{
if (int.TryParse(year, NumberStyles.Integer, _usCulture, out var val))
@@ -1265,7 +1305,7 @@ namespace MediaBrowser.MediaEncoding.Probing
}
}
- var premiereDateString = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaOriginalBroadcastDateTime");
+ var premiereDateString = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/MediaOriginalBroadcastDateTime");
if (!string.IsNullOrWhiteSpace(premiereDateString))
{
// Credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
@@ -1276,9 +1316,9 @@ namespace MediaBrowser.MediaEncoding.Probing
}
}
- var description = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/SubTitleDescription");
+ var description = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/SubTitleDescription");
- var subTitle = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/SubTitle");
+ var subTitle = FFProbeHelpers.GetDictionaryValue(data.Format.Tags, "WM/SubTitle");
// For below code, credit to MCEBuddy: https://mcebuddy2x.codeplex.com/
@@ -1334,24 +1374,25 @@ namespace MediaBrowser.MediaEncoding.Probing
{
video.Timestamp = GetMpegTimestamp(video.Path);
- _logger.LogDebug("Video has {timestamp} timestamp", video.Timestamp);
+ _logger.LogDebug("Video has {Timestamp} timestamp", video.Timestamp);
}
catch (Exception ex)
{
- _logger.LogError(ex, "Error extracting timestamp info from {path}", video.Path);
+ _logger.LogError(ex, "Error extracting timestamp info from {Path}", video.Path);
video.Timestamp = null;
}
}
}
}
+ // REVIEW: find out why the byte array needs to be 197 bytes long and comment the reason
private TransportStreamTimestamp GetMpegTimestamp(string path)
{
- var packetBuffer = new byte['Å'];
+ var packetBuffer = new byte[197];
- using (var fs = _fileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read))
+ using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
{
- fs.Read(packetBuffer, 0, packetBuffer.Length);
+ fs.Read(packetBuffer);
}
if (packetBuffer[0] == 71)
@@ -1359,7 +1400,7 @@ namespace MediaBrowser.MediaEncoding.Probing
return TransportStreamTimestamp.None;
}
- if ((packetBuffer[4] == 71) && (packetBuffer['Ä'] == 71))
+ if ((packetBuffer[4] == 71) && (packetBuffer[196] == 71))
{
if ((packetBuffer[0] == 0) && (packetBuffer[1] == 0) && (packetBuffer[2] == 0) && (packetBuffer[3] == 0))
{