HDL-ON_Android/FengLinVideo/Form/MonitorFragment.cs
New file @@ -0,0 +1,208 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using Android.App; using Android.Content; using Android.Icu.Text; using Android.OS; using Android.Runtime; using Android.Util; using Android.Views; using Android.Widget; using Com.ETouchSky; using Com.Tool; using HDL_ON.DAL.Server; using HDL_ON_Android.FengLinVideo.Interface; using Java.Util; using Org.Json; namespace HDL_ON_Android.FengLinVideo.Form { public class MonitorFragment : Fragment, View.IOnClickListener, VideoState { private View mView; private VideoPhone mPhone; // 截图 private LinearLayout screenshotLayout; private ImageView screenImage; private TextView ScreenText; //开锁 private LinearLayout unlockLayout; private ImageView unlockImag; private TextView unlockText; // 更新线程 private Thread thread = null; public MonitorFragment(VideoPhone phone) { this.mPhone = phone; } public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.Inflate(Resource.Layout.fragment_monitor, container, false); IniView(); return mView; } private void IniView() { screenshotLayout = (LinearLayout)mView.FindViewById(Resource.Id.icon_sceenshotLayout); screenImage = (ImageView)mView.FindViewById(Resource.Id.icon_sceenshotImg); ScreenText = (TextView)mView.FindViewById(Resource.Id.icon_sceenshotText); unlockLayout = (LinearLayout)mView.FindViewById(Resource.Id.icon_unlockLayout); unlockImag = (ImageView)mView.FindViewById(Resource.Id.icon_unlockImg); unlockText = (TextView)mView.FindViewById(Resource.Id.icon_unlockText); unlockLayout.SetOnClickListener(this); screenshotLayout.SetOnClickListener(this); } /// <summary> /// 开锁 /// </summary> private void Unlock() { if (mPhone != null) { try { unlockImag.Selected = true; JSONObject ht = new JSONObject(); ht.Put("command", "open");//固定参数 ht.Put("room_id", 123); ht.Put("devType", 7); mPhone.SendCustomData(ht.ToString()); } catch { } } } /// <summary> /// 更新开锁按钮状态 /// </summary> private void UpdataUnlockState() { try { //开锁成功,15秒内不给再点击按钮 unlockLayout.Enabled = false; if (thread != null) { try { thread.Interrupt(); } catch { } thread = null; } thread = new Thread(() => { try { Thread.Sleep(15 * 1000); Activity.RunOnUiThread(() => { if (unlockLayout != null) unlockLayout.Enabled = true; }); } catch { } }); thread.Start(); } catch { } } public void OnClick(View v) { // if (v.Equals(unlockLayout)) { if (mPhone != null) Unlock(); } else if (v.Equals(screenshotLayout)) { //有视频过来可调用此接口进行拍照 if (mPhone != null) { // 内部储存/DCIM/Camera/.....jpg screenImage.Selected = true; SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); string time = format.Format(new Date(SystemClock.CurrentThreadTimeMillis())); string ss = Android.OS.Environment.ExternalStorageDirectory.Path + "/DCIM/Camera"; string path = ss + "/" + time + ".jpg"; mPhone.Snap(path); } } } /// <summary> /// 通话状态回调方法 /// </summary> /// <param name="msg"></param> public void OnPhoneEvent(string msg) { try { // TextProtocol tp = new TextProtocol(); tp.Parse(msg); string event1 = tp.GetString("event"); switch (event1) { case "EVT_HangUp"://挂断 Activity.Finish(); break; case "EVT_RECV_CUSTOM_DATA": UpdataUnlockState(); break; case "EVT_SnapAck": int error = tp.GetInt("error"); string filePath = tp.GetString("filePath"); if (error == 0) { screenImage.Selected = true; } else { screenImage.Selected = false; } break; } } catch { } } public override void OnDestroy() { base.OnDestroy(); if (thread != null) { try { thread.Interrupt(); } catch { } thread = null; } } } } HDL-ON_Android/FengLinVideo/Form/ReverseCallFragment.cs
New file @@ -0,0 +1,404 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using Android.App; using Android.Content; using Android.Icu.Text; using Android.OS; using Android.Runtime; using Android.Util; using Android.Views; using Android.Widget; using Com.ETouchSky; using Com.Tool; using HDL_ON.Common; using HDL_ON.DAL.Server; using HDL_ON_Android.FengLinVideo.Interface; using Java.Util; using Org.Json; namespace HDL_ON_Android.FengLinVideo.Form { public class ReverseCallFragment : Fragment, View.IOnClickListener, VideoState { private VideoPhone mPhone; private string param = ""; private bool isCalling = false; private View mView; private ImageView screenshotImg;// 截图 private ImageView unlockImg;// 开锁 private LinearLayout answerLayout; // 接听 private ImageView hangupImg; // 接听 private ImageView answerImg;// 挂断 private TextView hangupText; private TextView tvTip; private System.Threading.Timer timer = null; private int Time = 0; public ReverseCallFragment(VideoPhone _phone, string _param) { this.mPhone = _phone; this.param = _param; } public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.Inflate(Resource.Layout.fragment_call, container, false); IniView(); ReverseCall(param); return mView; } private void IniView() { screenshotImg = (ImageView)mView.FindViewById(Resource.Id.callScreenshotImg);// unlockImg = (ImageView)mView.FindViewById(Resource.Id.callUnlockImg);// tvTip = (TextView)mView.FindViewById(Resource.Id.callTipText); answerLayout = (LinearLayout)mView.FindViewById(Resource.Id.callAnswerLayout); hangupImg = (ImageView)mView.FindViewById(Resource.Id.callHangupImg); answerImg = (ImageView)mView.FindViewById(Resource.Id.callAnswerImg); hangupText = (TextView)mView.FindViewById(Resource.Id.callHangupText); screenshotImg.SetOnClickListener(this); unlockImg.SetOnClickListener(this); hangupImg.SetOnClickListener(this); answerImg.SetOnClickListener(this); hangupText.SetText(GetString(Resource.String.video_not_answer), null); tvTip.SetText(GetString(Resource.String.calling), null); } /// <summary> /// 一般是推送过的来电信息时调用此接口打开视频窗口。然后可调用mPhone.acceptRing(param);接收来电信息 /// </summary> /// <param name="param"></param> private void ReverseCall(string param) { if (mPhone != null) { mPhone.ReverseCall(param); } } /// <summary> /// 开锁 /// </summary> private void Unlock() { //开锁,当收到来电信息时可进行开锁操作 if (mPhone != null) { try { unlockImg.Selected = true; JSONObject ht = new JSONObject(); ht.Put("command", "open");//固定参数 ht.Put("room_id", 123); //动态参数 ,传递开门的房间号。这个开门口记录就能记录谁开的门 ht.Put("devType", 7); //固定参数 mPhone.SendCustomData(ht.ToString()); } catch (Exception e) { string erro = e.Message; } } } /// <summary> /// 更新开锁按钮状态,开锁成功,15秒内不给再点击按钮 /// </summary> private void UpdataUnlockState() { try { if (unlockImg == null) return; unlockImg.Enabled = false; new Thread(() => { Thread.Sleep(15 * 1000); Activity.RunOnUiThread(() => { if (unlockImg != null) unlockImg.Enabled = true; }); }).Start(); } catch { } } private string GetTime(int time) { int m = time / 60; int s = time % 60; return UnitFormat(m) + ":" + UnitFormat(s); } private static string UnitFormat(int i) { string retStr = null; if (i >= 0 && i < 10) retStr = "0" + i; else retStr = "" + i; return retStr; } /// <summary> /// 通话记录计时器,从拉流成功开始计算时间 /// </summary> private void TimeStarts() { try { if (timer != null) timer.Dispose(); TimerCallback timerCallback = new TimerCallback(Tick); timer = new System.Threading.Timer(timerCallback, null, 0, 1000); } catch (Exception) { } } private void TimeEnd() { Time = 0; if (timer != null) { timer.Dispose(); timer = null; } } public void Tick(Object state) { try { Activity.RunOnUiThread(() => { try { Time++; if (tvTip != null) tvTip.SetText(GetTime(Time), null); } catch { } }); } catch { } } /// <summary> /// 通话消息回调方法 /// </summary> /// <param name="msg"></param> public void OnPhoneEvent(string msg) { try { // TextProtocol tp = new TextProtocol(); tp.Parse(msg); string event1 = tp.GetString("event"); switch (event1) { case "EVT_RECV_CUSTOM_DATA": string data = tp.GetString("data"); UpdataUnlockState(); break; case "EVT_StartStream":// 拉流成功,开始记录通话时间 isCalling = true; TimeStarts(); hangupText.SetText(GetString(Resource.String.video_hang_up), null); break; case "EVT_StopStream": if (isCalling == false) PostReject();// 拒接 else PostHangup();// 正常挂断 break; case "EVT_SnapAck": int error = tp.GetInt("error"); string filePath = tp.GetString("filePath"); if (error == 0) { screenshotImg.Selected = true; PostScreenshot(filePath); } else { screenshotImg.Selected = false; } break; } } catch (Exception e) { string error = e.Message; } } public void OnClick(View v) { if (v.Equals(answerImg)) { //接收来电 if (mPhone != null) { if (mPhone.IsRinging) { string UserData = "user text"; //注意:RequestAudio 请求对方音频,RequestVideo请求对方视频 SendAudio发送本地音频 SendVideo 发送本地视频 一般门口不接收到视频,所以最好设置0,减少流量消耗 string param = string.Format("RequestAudio=1\r\n" + "RequestVideo=1\r\n" + "SendAudio=1\r\n" + "SendVideo=0r\n" + "UserData=%s\r\n", UserData); mPhone.AcceptRing(param); answerLayout.Visibility = ViewStates.Gone; PostAnswer(); } } } else if (v.Equals(hangupImg)) { if (mPhone != null) { mPhone.HangUp(); TimeEnd(); } Activity.Finish(); } else if (v.Equals(screenshotImg)) { //有视频过来可调用此接口进行拍照 if (mPhone != null) { // 内部储存/DCIM/Camera/.....jpg screenshotImg.Selected = true; SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); string time = format.Format(new Date(SystemClock.CurrentThreadTimeMillis())); string ss = Android.OS.Environment.ExternalStorageDirectory.Path + "/DCIM/Camera"; string path = ss + "/" + time + ".jpg"; mPhone.Snap(path); } } else if (v.Equals(unlockImg)) { Unlock(); } } /// <summary> /// post 截图 /// </summary> /// <param name="path">截图保留的路径</param> private void PostScreenshot(string path) { new Thread(() => { try { string[] str = path.Split("/"); string img_name = str.GetValue(str.Length - 1).ToString().Replace(".jpg", ""); byte[] images = FileUtlis.Files.ReadFileForPath(path); Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("callId", VideoActivity.CallId); d.Add("images", images); d.Add("imagesName", img_name); string jsonString = HttpUtil.GetSignRequestJson(d); string url = "/home-wisdom/app/fl/vi/screenshot"; ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString); Log.Info("FengLinVideo", "Post Screenshot Response code=" + response.Code); } catch { } }).Start(); } /// <summary> /// post 接听电话记录 /// </summary> private void PostAnswer() { new Thread(() => { try { Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("uuid", VideoActivity.UUId);//丰林请求的唯一id string d.Add("cmtID", VideoActivity.CmtID);//丰林社区id string d.Add("roomno", VideoActivity.Roomno);//丰林房间号 string d.Add("unitno", VideoActivity.Unitno);//丰林楼栋号 string d.Add("HomeID", VideoActivity.HomeID);//丰林住宅id string d.Add("callId", VideoActivity.CallId);//呼叫记录id int string jsonString = HttpUtil.GetSignRequestJson(d); string url = "/home-wisdom/app/fl/vi/answer"; ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString); Log.Info("FengLinVideo", "Post Answer Response code=" + response.Code); } catch { } }).Start(); } /// <summary> /// post 挂断电话记录 /// </summary> private void PostHangup() { new Thread(() => { try { Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("callId", VideoActivity.CallId);//呼叫记录id int d.Add("callDuration", Time);//通话时长(秒) int string jsonString = HttpUtil.GetSignRequestJson(d); string url = "/home-wisdom/app/fl/vi/hang-up"; ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString); Log.Info("FengLinVideo", "Post Hangup Response code=" + response.Code); } catch { } }).Start(); } /// <summary> /// post 拒接记录 /// </summary> private void PostReject() { new Thread(() => { try { Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("callId", VideoActivity.CallId);//呼叫记录id int string jsonString = HttpUtil.GetSignRequestJson(d); string url = "/home-wisdom/app/fl/vi/reject"; ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString); Log.Info("FengLinVideo", "Post Reject Response code=" + response.Code); } catch { } }).Start(); } } } HDL-ON_Android/FengLinVideo/Interface/VideoState.cs
New file @@ -0,0 +1,8 @@ using System; namespace HDL_ON_Android.FengLinVideo.Interface { public interface VideoState { void OnPhoneEvent(string msg); } } HDL-ON_Android/FengLinVideo/widget/TipDiaglog.cs
New file @@ -0,0 +1,143 @@ using System; using Android.App; using Android.Content; using Android.Graphics; using Android.Views; using Android.Widget; using HDL_ON_Android; namespace GateWay.Droid.FengLinVideo.widget { public class TipDiaglog : Dialog, View.IOnClickListener, View.IOnTouchListener { private Context mContext = null; private string titleText = "提示"; private string contentText = ""; private string confirmText = "确认"; private bool isClose = false; private TextView contentView = null; private TextView titleView = null; private TextView okView = null; public object Tag = null; private OnConfirmClickListener onConfirmClickListener; public TipDiaglog(Context context) : base(context, Resource.Style.DialogTheme) { this.mContext = context; } public void SetAutoClose(bool bol) { this.isClose = bol; } public void SetTitleText(string _titleText) { titleText = _titleText; if (titleView != null) { titleView.SetText(titleText, null); } } public void SetContentText(string _contentText) { contentText = _contentText; if (contentView != null) { contentView.SetText(contentText, null); } } public void SetConfirmText(string text) { confirmText = text; if (okView != null) { okView.SetText(confirmText, null); } } public override void Create() { base.Create(); try { SetContentView(Resource.Layout.dialog_tip); contentView = (TextView)FindViewById(Resource.Id.tv_content); titleView = (TextView)FindViewById(Resource.Id.tv_title); okView = (TextView)FindViewById(Resource.Id.tv_ok); contentView.SetText(contentText, null); titleView.SetText(titleText, null); okView.SetText(confirmText, null); okView.SetOnTouchListener(this); okView.SetOnClickListener(this); } catch (Exception e) { string error = e.Message; } } public override void OnWindowFocusChanged(bool hasFocus) { base.OnWindowFocusChanged(hasFocus); try { Display display = ((Activity)mContext).WindowManager.DefaultDisplay; WindowManagerLayoutParams p = Window.Attributes; Point point = new Point(); display.GetSize(point); p.Width = (int)(point.X * 0.7); Window.SetGravity(GravityFlags.Center); } catch (Exception e) { string ss = e.Message; } } public void SetConfirmClickListener(OnConfirmClickListener l) { onConfirmClickListener = l; } public void OnClick(View v) { if (v.Equals(okView)) { if (onConfirmClickListener != null) onConfirmClickListener.onSureClick(this, v, isClose); } } public bool OnTouch(View v, MotionEvent e) { if (e.Action == MotionEventActions.Down) { v.SetBackgroundResource(Resource.Drawable.sure_background_sel); } else if (e.Action == MotionEventActions.Up) { v.SetBackgroundResource(Resource.Drawable.sure_background_def); } return false; } public interface OnConfirmClickListener { void onSureClick(TipDiaglog dialoog, View v,bool bol); } } } HDL-ON_Android/HDL-ON_Android.csproj
@@ -128,6 +128,24 @@ <Reference Include="AndriodBluetoothLibrary"> <HintPath>..\DLL\Android\AndriodBluetoothLibrary.dll</HintPath> </Reference> <Reference Include="cloudp2p"> <HintPath>..\..\..\未命名文件夹\cloudp2p.dll</HintPath> </Reference> <Reference Include="corelooper"> <HintPath>..\..\..\未命名文件夹\corelooper.dll</HintPath> </Reference> <Reference Include="crypt"> <HintPath>..\..\..\未命名文件夹\crypt.dll</HintPath> </Reference> <Reference Include="http"> <HintPath>..\..\..\未命名文件夹\http.dll</HintPath> </Reference> <Reference Include="VideoLibs"> <HintPath>..\..\..\未命名文件夹\VideoLibs.dll</HintPath> </Reference> <Reference Include="videophone"> <HintPath>..\..\..\未命名文件夹\videophone.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <Compile Include="MainActivity.cs" /> @@ -140,6 +158,11 @@ <Compile Include="Other\JLCountrycode.cs" /> <Compile Include="Other\JPush\JPushReceiver.cs" /> <Compile Include="Other\JPush\JPushService.cs" /> <Compile Include="VideoActivity.cs" /> <Compile Include="FengLinVideo\Interface\VideoState.cs" /> <Compile Include="FengLinVideo\Form\MonitorFragment.cs" /> <Compile Include="FengLinVideo\Form\ReverseCallFragment.cs" /> <Compile Include="FengLinVideo\widget\TipDiaglog.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> @@ -221,6 +244,86 @@ <Generator> </Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\answer.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\back_icon.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\dialog_background.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\hangup.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\mic.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\screenshot_def.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\screenshot_sel.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\screenshot.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\sure_background_def.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\sure_background_sel.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\tip_background.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\unlock_def.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\unlock_sel.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\unlock.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\drawable\video_background.png"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\layout\activity_video_phone.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\layout\dialog_tip.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\layout\fragment_call.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\layout\fragment_monitor.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> <AndroidResource Include="Resources\values-zh\strings.xml"> <SubType></SubType> <Generator></Generator> </AndroidResource> </ItemGroup> <ItemGroup> <Folder Include="Resources\drawable\" /> @@ -260,6 +363,12 @@ <PackageReference Include="Bugly"> <Version>4.3.1</Version> </PackageReference> <PackageReference Include="Xamarin.Android.Support.Constraint.Layout"> <Version>1.1.0</Version> </PackageReference> <PackageReference Include="Xamarin.Android.Support.Constraint.Layout.Solver"> <Version>1.1.0</Version> </PackageReference> </ItemGroup> <ItemGroup> <AndroidAsset Include="Assets\Language.ini" /> HDL-ON_Android/Resources/Resource.designer.cs
Diff too large HDL-ON_Android/Resources/drawable/answer.png
HDL-ON_Android/Resources/drawable/back_icon.png
HDL-ON_Android/Resources/drawable/dialog_background.xml
New file @@ -0,0 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <corners android:radius="20dp" /> <solid android:color="#FFFFFF" /> </shape> </item> </selector> HDL-ON_Android/Resources/drawable/hangup.png
HDL-ON_Android/Resources/drawable/mic.png
HDL-ON_Android/Resources/drawable/screenshot.xml
New file @@ -0,0 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/screenshot_sel" android:state_selected="true" /> <item android:drawable="@drawable/screenshot_sel" android:state_pressed="true" /> <item android:drawable="@drawable/screenshot_def" /> </selector> HDL-ON_Android/Resources/drawable/screenshot_def.png
HDL-ON_Android/Resources/drawable/screenshot_sel.png
HDL-ON_Android/Resources/drawable/sure_background_def.xml
New file @@ -0,0 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle"> <solid android:color="#ffffff" /> <corners android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp"/> </shape> </item> </layer-list> HDL-ON_Android/Resources/drawable/sure_background_sel.xml
New file @@ -0,0 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle"> <solid android:color="#66000000" /> <corners android:bottomLeftRadius="20dp" android:bottomRightRadius="20dp"/> </shape> </item> </layer-list> HDL-ON_Android/Resources/drawable/tip_background.xml
New file @@ -0,0 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle"> <solid android:color="#66000000" /> <corners android:radius="20dp"/> <padding android:left="20dp" android:right="20dp" android:bottom="8dp" android:top="8dp"/> </shape> </item> </layer-list> HDL-ON_Android/Resources/drawable/unlock.xml
New file @@ -0,0 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/unlock_sel" android:state_selected="true" /> <item android:drawable="@drawable/unlock_sel" android:state_pressed="true" /> <item android:drawable="@drawable/unlock_def" /> </selector> HDL-ON_Android/Resources/drawable/unlock_def.png
HDL-ON_Android/Resources/drawable/unlock_sel.png
HDL-ON_Android/Resources/drawable/video_background.png
HDL-ON_Android/Resources/layout/activity_video_phone.xml
New file @@ -0,0 +1,66 @@ <?xml version="1.0" encoding="UTF-8" ?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="44dp"> <ImageView android:id="@+id/videoBackImg" android:layout_width="wrap_content" android:layout_height="20dp" android:layout_marginLeft="10dp" android:layout_centerVertical="true" android:contentDescription="@string/video_icon" android:src="@drawable/back_icon"/> <TextView android:id="@+id/nameText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/colorBlack" android:layout_gravity="center_horizontal" android:textSize="@dimen/tipTitleTextSize" android:layout_centerInParent="true" android:text="@string/video_device"/> </RelativeLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="210" android:orientation="vertical" android:background="@drawable/video_background"> <FrameLayout android:id="@+id/locaVideo" android:layout_width="1px" android:layout_height="1px" android:visibility="invisible"/> <FrameLayout android:id="@+id/remoteFrame" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="393" android:orientation="vertical"> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"/> </LinearLayout> </LinearLayout> HDL-ON_Android/Resources/layout/dialog_tip.xml
New file @@ -0,0 +1,48 @@ <?xml version="1.0" encoding="UTF-8" ?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/dialog_background"> <TextView android:id="@+id/tv_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/color_default" android:textSize="@dimen/tipTitleTextSize" android:gravity="center" android:layout_marginTop="24dp" android:layout_marginBottom="12dp" android:fontFamily="sans-serif-black" android:text="@string/video_tip"/> <TextView android:id="@+id/tv_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="13sp" android:gravity="center" android:textColor="@color/color_default" android:text="@string/video_hang_up"/> <View android:layout_width="match_parent" android:layout_height="1px" android:layout_marginTop="24dp" android:background="@color/color_disable"/> <TextView android:id="@+id/tv_ok" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="13dp" android:paddingBottom="13dp" android:gravity="center" android:fontFamily="sans-serif-medium" android:textSize="16sp" android:textColor="#2175d8" android:background="@drawable/sure_background_def" android:text="@string/video_confirm"/> </LinearLayout> HDL-ON_Android/Resources/layout/fragment_call.xml
New file @@ -0,0 +1,133 @@ <?xml version="1.0" encoding="UTF-8" ?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="30dp" android:layout_marginRight="30dp" android:orientation="horizontal"> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1"> <ImageView android:id="@+id/callScreenshotImg" android:layout_width="40dp" android:layout_height="40dp" android:adjustViewBounds="true" android:scaleType="centerInside" android:layout_marginTop="16dp" android:layout_marginBottom="16dp" android:layout_marginLeft="13dp" android:layout_marginRight="13dp" android:contentDescription="@string/video_screenshot" android:src="@drawable/screenshot"/> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1"> <ImageView android:id="@+id/callUnlockImg" android:layout_width="40dp" android:layout_height="40dp" android:adjustViewBounds="true" android:scaleType="centerInside" android:layout_marginTop="16dp" android:layout_marginBottom="16dp" android:layout_marginLeft="13dp" android:layout_marginRight="13dp" android:contentDescription="@string/video_unlock" android:src="@drawable/unlock"/> </LinearLayout> </LinearLayout> <TextView android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="72dp" android:background="#806D798D"/> <TextView android:id="@+id/callTipText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@android:color/white" android:textSize="@dimen/tipTextSize" android:background="@drawable/tip_background" android:layout_centerHorizontal="true" android:layout_marginTop="110dp"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="30dp" android:layout_marginEnd="30dp" android:layout_below="@id/callTipText" android:layout_marginTop="103dp" android:orientation="horizontal"> <LinearLayout android:layout_width="66dp" android:layout_weight="1" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/callHangupImg" android:layout_width="66dp" android:layout_height="66dp" android:adjustViewBounds="true" android:contentDescription="@string/video_not_answer" android:scaleType="centerInside" android:src="@drawable/hangup"/> <TextView android:id="@+id/callHangupText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/video_not_answer"/> </LinearLayout> <LinearLayout android:id="@+id/callAnswerLayout" android:layout_width="66dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageView android:id="@+id/callAnswerImg" android:layout_width="66dp" android:layout_height="66dp" android:adjustViewBounds="true" android:contentDescription="@string/video_answer" android:scaleType="centerInside" android:src="@drawable/answer"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/video_answer"/> </LinearLayout> </LinearLayout> </RelativeLayout> HDL-ON_Android/Resources/layout/fragment_monitor.xml
New file @@ -0,0 +1,63 @@ <?xml version="1.0" encoding="UTF-8" ?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/icon_sceenshotLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_marginStart="60dp" android:layout_marginTop="60dp" android:orientation="vertical"> <ImageView android:id="@+id/icon_sceenshotImg" android:layout_width="66dp" android:layout_height="66dp" android:contentDescription="@string/video_screenshot" android:adjustViewBounds="true" android:scaleType="centerInside" android:src="@drawable/screenshot"/> <TextView android:id="@+id/icon_sceenshotText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="19dp" android:text="@string/video_screenshot"/> </LinearLayout> <LinearLayout android:id="@+id/icon_unlockLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_alignParentEnd="true" android:layout_marginEnd="60dp" android:layout_marginTop="60dp" android:orientation="vertical"> <ImageView android:id="@+id/icon_unlockImg" android:layout_width="66dp" android:layout_height="66dp" android:contentDescription="@string/video_unlock" android:adjustViewBounds="true" android:scaleType="centerInside" android:src="@drawable/unlock"/> <TextView android:id="@+id/icon_unlockText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="19dp" android:text="@string/video_unlock"/> </LinearLayout> </RelativeLayout> HDL-ON_Android/Resources/values-zh/strings.xml
New file @@ -0,0 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> <resources> <string name="app_name">HDL_ON_Pro</string> <string name="action_settings">设置</string> <string name="video_screenshot">截图</string> <string name="video_unlock">开锁</string> <string name="video_answer">接听</string> <string name="video_not_answer">拒接</string> <string name="video_tip">提示</string> <string name="video_hang_up">已挂断</string> <string name="video_confirm">确定</string> <string name="video_icon">图标</string> <string name="video_device">设备</string> <string name="video_success">成功</string> <string name="video_fail">失败</string> <string name="calling">来电中...</string> <string name="end_call">通话结束</string> <string name="on_the_phone">通话中...</string> <string name="unlock_success">开锁成功</string> <string name="screenshot_success">截图成功</string> </resources> HDL-ON_Android/Resources/values/colors.xml
@@ -3,4 +3,9 @@ <color name="colorPrimary">#2c3e50</color> <color name="colorPrimaryDark">#1B3147</color> <color name="colorAccent">#3498db</color> <color name="colorBlack">#FF000000</color> <color name="color_white">#FFFFFF</color> <color name="color_disable">#CCCCCC</color> <color name="color_select">#FB744A</color> <color name="color_default">#FF333333</color> </resources> HDL-ON_Android/Resources/values/dimens.xml
@@ -1,4 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <resources> <dimen name="fab_margin">16dp</dimen> <dimen name="titleTextSize">25sp</dimen> <dimen name="tipTextSize">14sp</dimen> <dimen name="tipTitleTextSize">16sp</dimen> </resources> HDL-ON_Android/Resources/values/strings.xml
@@ -1,5 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> <resources> <string name="app_name">HDL_ON_Pro</string> <string name="action_settings">Settings</string> <string name="action_settings">Setting</string> <string name="video_screenshot">Screenshot</string> <string name="video_unlock">Unlock</string> <string name="video_answer">Answer</string> <string name="video_not_answer">Reject</string> <string name="video_tip">Prompt</string> <string name="video_hang_up">Hang up</string> <string name="video_confirm">Confirm</string> <string name="video_icon">Icon</string> <string name="video_device">Device</string> <string name="video_success">Success</string> <string name="video_fail">Fail</string> <string name="calling">Calling...</string> <string name="end_call">End of call</string> <string name="on_the_phone">On the phone</string> <string name="unlock_success">Unlock successfully</string> <string name="screenshot_success">Screenshot successfully</string> </resources> HDL-ON_Android/Resources/values/styles.xml
@@ -9,7 +9,6 @@ <item name="android:windowNoTitle">true</item> <item name="android:windowTranslucentStatus">true</item> </style> <style name="MyDialogStyle"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowFrame">@null</item> @@ -20,5 +19,22 @@ <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> <item name="android:backgroundDimEnabled">true</item> </style> <style name="DialogTheme" parent="@android:style/Theme.Dialog"> <!-- 背景颜色及和透明程度 --> <item name="android:windowBackground">@android:color/transparent</item> <!-- 是否去除标题 --> <item name="android:windowNoTitle">true</item> <!-- 是否去除边框 --> <item name="android:windowFrame">@null</item> <!-- 是否浮现在activity之上 --> <item name="android:windowIsFloating">true</item> </style> <style name="MyTheme1" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowBackground">@drawable/Loading</item> <!-- 隐藏状态栏 --> <item name="android:windowFullscreen">false</item> <!-- 隐藏标题栏 --> <item name="android:windowNoTitle">true</item> <item name="android:windowTranslucentStatus">false</item> </style> </resources> HDL-ON_Android/VideoActivity.cs
New file @@ -0,0 +1,449 @@ using System; using System.Collections.Generic; using System.Threading; using Android; using Android.App; using Android.Content; using Android.Content.PM; using Android.Graphics; using Android.OS; using Android.Runtime; using Android.Support.V4.App; using Android.Support.V4.Content; using Android.Util; using Android.Views; using Android.Widget; using Com.ETouchSky; using Com.Tool; using GateWay.Droid.FengLinVideo.widget; using HDL_ON.Common; using HDL_ON.DAL.Server; using HDL_ON_Android.FengLinVideo.Form; namespace HDL_ON_Android { [Activity(Label = "VideoActivity", WindowSoftInputMode = SoftInput.AdjustResize, LaunchMode = LaunchMode.SingleInstance, ConfigurationChanges = (ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.LayoutDirection | ConfigChanges.Locale | ConfigChanges.Orientation | ConfigChanges.ScreenSize), Theme = "@style/MyTheme1", ScreenOrientation = ScreenOrientation.Portrait)] public class VideoActivity : Activity, View.IOnClickListener, ISurfaceHolderCallback, VideoPhoneJni.ICallBack, TipDiaglog.OnConfirmClickListener { private static Activity activity; private VideoPhone mPhone; private ISurfaceHolder mRemoteSurfaceHolder; private FrameLayout mRemoteFrameContainer; private SurfaceView mSurfaceRemote; private ImageView ivBack; private TextView tvName; private MonitorFragment monitorFragment = null; private ReverseCallFragment reverseCallFragment = null; public static string ESVideoUUID = "JJY000019VPLLF";//室外机UUID,例:JJY000007FSEYX f5f6fa public static string DeviceName;//室外机的名称,例,室外机 public static bool IsCollect;//是否收藏 public static int Tpye = 0;//类型,0 监控,1反呼 public static string UUId; public static int CallId;//callId 呼叫记录id public static string CmtID;//cmtID 丰林社区号 public static string Roomno;//roomno 丰林房间号 public static string Unitno;//unitno 丰林楼栋号 string public static string HomeID;//HomeID 丰林住宅id protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); try { activity = this; ESVideoUUID = Intent.GetStringExtra("ESVideoUUID");//室外机UUID,例:JJY000007FSEYX DeviceName = Intent.GetStringExtra("DeviceName");//室外机的名称,例,室外机 UUId = Intent.GetStringExtra("uuid");// CallId = Intent.GetIntExtra("callId", 0); CmtID = Intent.GetStringExtra("cmtID"); Roomno = Intent.GetStringExtra("roomno"); Unitno = Intent.GetStringExtra("unitno"); HomeID = Intent.GetStringExtra("HomeID"); IsCollect = Intent.GetBooleanExtra("IsCollect", false);//是否收藏 Tpye = Intent.GetIntExtra("Type", 0);//类型,0 监控,1反呼 SetContentView(Resource.Layout.activity_video_phone); IniView(); IniData(); if (Tpye == 0) { Monitor(ESVideoUUID); //监控 monitorFragment = new MonitorFragment(mPhone); FragmentManager.BeginTransaction().Replace(Resource.Id.content, monitorFragment).Commit(); } else { string param = "address=" + ESVideoUUID + ",tag=mobile://123,"; reverseCallFragment = new ReverseCallFragment(mPhone, param); FragmentManager.BeginTransaction().Replace(Resource.Id.content, reverseCallFragment).Commit(); } } catch {} } /// <summary> /// 必要的一些权限 /// </summary> private void Permissions() { String[] mPermissionList = new String[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage, Manifest.Permission.Camera, Manifest.Permission.RecordAudio }; foreach (String permissions in mPermissionList) { if (ContextCompat.CheckSelfPermission(this, permissions) != 0) { ActivityCompat.RequestPermissions(this, new string[] { permissions }, 1); } } } /// <summary> /// 隐藏底部导航栏——虚拟按键 /// </summary> private void HideVirtualButtons() { WindowManagerLayoutParams windowManager = Window.Attributes; var uiOptions = (int)Window.DecorView.SystemUiVisibility; var newUiOptions = (int)uiOptions; newUiOptions = (int)SystemUiFlags.HideNavigation | (int)SystemUiFlags.Immersive | (int)SystemUiFlags.ImmersiveSticky; windowManager.SystemUiVisibility = (StatusBarVisibility)newUiOptions; Window.Attributes = windowManager; } /// <summary> /// 监控 /// </summary> /// <param name="address"></param> private void Monitor(string address) { //监视功能 从平台拉取监视列表,调用此接口可以一台一台监视 if (mPhone != null) { //此参数 可以向门口机设备传递数据, //注意:RequestAudio 请求对方音频,RequestVideo请求对方视频 SendAudio发送本地音频 SendVideo 发送本地视频 一般门口不接收到视频,所以最好设置0,减少流量消耗 string UserData = ""; string param = "SendAudio=0\r\n" + "SendVideo=0\r\n" + "RequestAudio=0\r\n" + "RequestVideo=0\r\n" + "UserData=" + UserData + "\r\n"; mPhone.Monitor(address, param); } } private void IniView() { mRemoteFrameContainer = (FrameLayout)FindViewById(Resource.Id.remoteFrame); ivBack = (ImageView)FindViewById(Resource.Id.videoBackImg); tvName = (TextView)FindViewById(Resource.Id.nameText); tvName.SetText(DeviceName, null); ivBack.SetOnClickListener(this); } private void IniData() { try { if (mPhone == null) { string _params = "port=8554\r\n" + "packcode=1021df37c2abe546a4541ca2c4a9c910\r\n"; //初始化对讲端口,默认就好,跟门口机设置要匹配,注意新接口需要增加packcode参数,需要把你们的包名发过来 mPhone = new VideoPhone(this, this, _params); if (mRemoteSurfaceHolder != null) { mPhone.SetRemoteSurfaceHolder(mRemoteSurfaceHolder, "mRemoteSurfaceHolder!=null"); //设置来电窗口 } ViewGroup v = (ViewGroup)FindViewById(Resource.Id.localVideo); mPhone.SetLocalVideoContainer(v);//设置本地视频窗口,一定要调用,不然后会出现没声音 } else { mPhone.StopStream(); mPhone.Release(); mPhone = null; } } catch { } } protected override void OnResume() { base.OnResume(); HideVirtualButtons(); Permissions(); if (mPhone != null) { mPhone.OnActivityResume(); } } protected override void OnPause() { base.OnPause(); if (mPhone != null) { //mPhone.OnActivityPause(); } } protected override void OnDestroy() { base.OnDestroy(); if (mPhone != null) { mPhone.HangUp(); mPhone.Release(); mPhone = null; //mPhone.OnActivityDestroy(); } } public override void OnBackPressed() { if (mPhone != null) mPhone.HangUp(); Finish(); } public void OnClick(View v) { if (v.Equals(ivBack)) { if (mPhone != null) mPhone.HangUp(); Finish(); } } /// <summary> /// show出视频画面 /// 不能用View.INVISIBLE来完全隐藏,否则MediaCodec.configure会报ava.lang.IllegalArgumentException: The surface has been released /// </summary> private void ShowRemoteVideo() { try { if (mSurfaceRemote != null) { return; } mSurfaceRemote = new SurfaceView(this, null); ISurfaceHolder holder = mSurfaceRemote.Holder; holder.AddCallback(this);//ISurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS holder.SetType(SurfaceType.PushBuffers); //发现第一次show时会闪屏一下,后面hide再show时不会闪屏 FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); //v.setId(View.generateViewId()); mSurfaceRemote.LayoutParameters = lp; mRemoteFrameContainer.AddView(mSurfaceRemote); } catch { } } /// <summary> /// 关闭画面 /// </summary> private void HideRemoteVideo() { try { if (mSurfaceRemote != null) { mRemoteFrameContainer.RemoveView(mSurfaceRemote); mSurfaceRemote = null; } } catch { } } /// <summary> /// 弹出已挂断提示 /// </summary> private void ShowTipDialog(string title, string text, string btnText, bool isClose) { try { TipDiaglog diaglog = new TipDiaglog(this); diaglog.SetAutoClose(isClose); diaglog.SetTitleText(title);//"提示" diaglog.SetContentText(text);//"已挂断" diaglog.SetConfirmText(btnText);//"确认" diaglog.SetCanceledOnTouchOutside(false); diaglog.Show(); diaglog.Create(); diaglog.SetConfirmClickListener(this); } catch (Exception e) { string ss = e.Message; } } public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height) { mRemoteSurfaceHolder = holder; if (mPhone != null) { mPhone.SetRemoteSurfaceHolder(holder, "surfaceChanged"); } } public void SurfaceCreated(ISurfaceHolder holder) { mRemoteSurfaceHolder = holder; if (mPhone != null) { mPhone.SetRemoteSurfaceHolder(holder, "surfaceCreated"); } } public void SurfaceDestroyed(ISurfaceHolder holder) { mRemoteSurfaceHolder = null; if (mPhone != null) { mPhone.SetRemoteSurfaceHolder(null, "surfaceDestroyed"); } } /// <summary> /// 开始拉流 /// 注意:由于android框架限制,要满足如下条件才能开流:activity要在前台,并且surfaceview可用 /// </summary> /// <param name="reason"></param> private void StartStream(String reason) { if (mPhone != null) { try { //开流之前可配置视频尺寸,码率,帧率 针对的是本地 //mPhone.SetVideoSize(640, 480);//1920x1080,1280x720,640x480 //mPhone.SetBps(1.5 * 1024 * 1024); //mPhone.SetFps(30); mPhone.StartStream(); } catch { } } } /// <summary> /// 通话状态回调方法 /// </summary> /// <param name="msg"></param> public void OnPhoneEvent(string msg) { try { if (monitorFragment != null) { monitorFragment.OnPhoneEvent(msg); } if (reverseCallFragment != null) { reverseCallFragment.OnPhoneEvent(msg); } TextProtocol tp = new TextProtocol(); tp.Parse(msg); string event1 = tp.GetString("event"); Log.Info("FengLinVideo", "OnPhoneEvent event=" + event1); switch (event1) { case "EVT_Ringing": mPhone.RequestCallerSendVideo(); ShowRemoteVideo(); break; case "EVT_Connected": if (!mPhone.IsStreamRunning) { //由于android框架限制,要满足如下条件才能开流: activity要在前台,并且surfaceview可用 StartStream("EVT_Connected"); } ShowRemoteVideo(); break; case "EVT_StartStream": StartStream("EVT_StreamStream"); break; case "EVT_StopStream": mPhone.StopStream(); break; case "EVT_MonitorConnected": if (!mPhone.IsStreamRunning) { StartStream("EVT_MonitorConnected"); } ShowRemoteVideo(); break; case "EVT_HangUp": HideRemoteVideo(); if (mPhone != null) { mPhone.StopStream(); } //Toast.MakeText(this, GetString(Resource.String.end_call), ToastLength.Short).Show(); this.Finish(); //ShowTipDialog(tip, hang_up, confirm, true); break; case "EVT_RECV_CUSTOM_DATA": string data = tp.GetString("data"); Toast.MakeText(this, GetString(Resource.String.video_success), ToastLength.Short).Show(); break; case "EVT_SnapAck": int error = tp.GetInt("error"); string filePath = tp.GetString("filePath"); if (error == 0) { Toast.MakeText(this, GetString(Resource.String.video_success), ToastLength.Short).Show(); } else { Toast.MakeText(this, GetString(Resource.String.video_fail), ToastLength.Short).Show(); } break; } } catch { } } public void OnRecvAudioFrame(byte[] p0) { //throw new NotImplementedException(); } public void OnRecvVideoFrame(byte[] p0) { //throw new NotImplementedException(); } public void onSureClick(TipDiaglog dialoog, View v, bool bol) { dialoog.Dismiss(); if (bol) this.Finish(); } } } HDL-ON_iOS/.DS_StoreBinary files differ
HDL_ON/Common/FileUtlis.cs
@@ -26,7 +26,8 @@ string RootPath = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/"; string accountPath; string AccountPath { string AccountPath { get { if (string.IsNullOrEmpty(accountPath) || !accountPath.Contains(UserInfo.Current.ID)) @@ -232,8 +233,6 @@ } } public byte[] ReadFile(string fileName) { FileStream fs = null; @@ -275,7 +274,43 @@ } } // 读取指定路径文件内容 public byte[] ReadFileForPath(string path) { FileStream fs = null; try { if (File.Exists(path)) { fs = new FileStream(path, FileMode.Open, FileAccess.Read); } else { return new byte[0]; } byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, bytes.Length); return bytes; } catch { return new byte[0]; } finally { try { if (fs != null) { fs.Close(); } } catch { } } } /// <summary> /// 下载网络图片 @@ -286,7 +321,8 @@ { if (!File.Exists(fileName)) { System.Threading.Tasks.Task.Run(() => { System.Threading.Tasks.Task.Run(() => { FileStream fs = null; try { @@ -297,7 +333,8 @@ fs.Write(recevieBytes, 0, recevieBytes.Length); fs.Flush(); } catch (Exception ex) { catch (Exception ex) { MainPage.Log($"down image : {ex.Message}"); } finally @@ -309,7 +346,8 @@ } } }); }else } else { action?.Invoke(); } HDL_ON/FengLinVideo/ESOnVideo.cs
New file @@ -0,0 +1,134 @@ using System; using Android.Content; namespace HDL_ON.FengLinVideo { public class ESOnVideo { /// <summary> /// 丰林可视对讲 /// </summary> private static ESOnVideo m_Current = null; /// <summary> /// /// </summary> public static ESOnVideo Current { get { if (m_Current == null) { m_Current = new ESOnVideo(); } return m_Current; } } public void InitESVideoSDK() { //ESVideo. } /// <summary> /// 监控页面 /// </summary> /// <param name="mESVideoInfo"></param> public void ShowESVideoMonitor(ESVideoInfo mESVideoInfo) { Intent intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity)); intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID); intent.PutExtra("uuid", mESVideoInfo.uuid); intent.PutExtra("DeviceName", mESVideoInfo.DeviceName); intent.PutExtra("cmtID", mESVideoInfo.cmtID); intent.PutExtra("roomno", mESVideoInfo.roomno); intent.PutExtra("unitno", mESVideoInfo.unitno); intent.PutExtra("HomeID", mESVideoInfo.HomeID); intent.PutExtra("callId", mESVideoInfo.callId); intent.PutExtra("Type", 0); Shared.Application.Activity.StartActivity(intent); } /// <summary> /// 被呼叫页面 /// </summary> /// <param name="mESVideoInfo"></param> public void ShowESvideoVideoIntercom(ESVideoInfo mESVideoInfo) { Intent intent = new Intent(Shared.Application.Activity, typeof(HDL_ON_Android.VideoActivity)); intent.PutExtra("ESVideoUUID", mESVideoInfo.ESVideoUUID); intent.PutExtra("uuid", mESVideoInfo.uuid); intent.PutExtra("DeviceName", mESVideoInfo.DeviceName); intent.PutExtra("cmtID", mESVideoInfo.cmtID); intent.PutExtra("roomno", mESVideoInfo.roomno); intent.PutExtra("unitno", mESVideoInfo.unitno); intent.PutExtra("HomeID", mESVideoInfo.HomeID); intent.PutExtra("callId", mESVideoInfo.callId); intent.PutExtra("Type", 1); Shared.Application.Activity.StartActivity(intent); } /// <summary> /// 测试方法 /// </summary> /// <param name="isMonitor"></param> public void Test(bool isMonitor = true) { ESVideoInfo eSVideoInfo = new ESVideoInfo() { DeviceName = "室外机88", ESVideoUUID = "JJY000019VPLLF", }; if (isMonitor) { ShowESVideoMonitor(eSVideoInfo); } else { ShowESvideoVideoIntercom(eSVideoInfo); } } } public class ESVideoInfo { /// <summary> /// 室外机的UUID /// 例:JJY000007FSEYX /// </summary> public string ESVideoUUID = string.Empty; /// <summary> /// 室外机的名称 /// 例:室外机 /// </summary> public string DeviceName = string.Empty; /// <summary> /// 丰林请求的唯一id /// </summary> public string uuid; /// <summary> /// 丰林社区id /// </summary> public string cmtID; /// <summary> /// 丰林房间号 /// </summary> public string roomno; /// <summary> /// 丰林楼栋号 /// </summary> public string unitno; /// <summary> /// 丰林住宅Id /// </summary> public string HomeID; /// <summary> /// 呼叫记录Id /// </summary> public string callId; } } HDL_ON/HDL_ON.projitems
@@ -379,6 +379,7 @@ <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\AddFunction\DeviceListPage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\PirDevice\View\MainView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\PirDevice\View\HeigthChangeView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)FengLinVideo\ESOnVideo.cs" /> </ItemGroup> <ItemGroup> <Folder Include="$(MSBuildThisFileDirectory)DAL\" /> HDL_ON/UI/UI2/4-PersonalCenter/AboutOn/AboutOnPage.cs
@@ -5,6 +5,7 @@ using System.Text; using HDL_ON.DAL.Server; using System.Threading.Tasks; using HDL_ON.FengLinVideo; namespace HDL_ON.UI { @@ -71,6 +72,19 @@ }; bodyView.AddChidren(btnOnTitle); #if DEBUG btnOnIcon.MouseUpEventHandler += (sender, e) => { ESOnVideo.Current.Test(); }; btnOnTitle.MouseUpEventHandler += (sender, e) => { ESOnVideo.Current.Test(false); }; #endif Button btnOnVersion = new Button() { Y = btnOnTitle.Bottom, HdlBluWi/.DS_StoreBinary files differ